Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Introduction to Dapr (Distributed Application
Runtime)
Yevhen Bova
2021-02-25
2
www.luxoft.com
Short bio
 Java Developer at Luxoft
 10 years of experience in Java
 Involved in the development of:
 A huge OSGI-baseddesktop application(600+ modules, 300+ third-partymodules)
 Server-side - microservices
Eugene Bova "Dapr (Distributed Application Runtime) in a Microservices Architecture"
4
www.luxoft.com
Project overview
 https://dapr.io/
 Initiated by Microsoft
 Open-source project (MIT License) - https://github.com/dapr/dapr
 Initial version: 0.1 released in Oct 2019
 Current version: v1.0 released on Feb 17
5
www.luxoft.com
High-level architecture diagram
6
www.luxoft.com
Building blocks (API)
7
www.luxoft.com
Hosting environments
• Self-hosted
• Dapr runtime needs to be launched via CL
• Kubernetes-hosted
• Dapr side-car container injected into pod
8
www.luxoft.com
Self-hosted
9
www.luxoft.com
Kubernetes-hosted
10
www.luxoft.com
Launching locally
dapr run --app-id myservice 
--app-port 8081 
--app-protocol http 
-- java -Dserver.port=8081 -jar com.example.myservice.jar
11
www.luxoft.com
Service invocation API
Overview
12
www.luxoft.com
Service invocation API
Features
• All calls between Dapr applications can be made secure with mutual authentication (mTLS)
• Supports calls across namespaces
• Performs retries
• Observability
• All calls between applications are traced, and metrics are gathered to provide insights and diagnostics for applications
• Uses W3C tracing context
• Integrates with OpenTelemetry for tracing, metrics, and logs
• Access Control Lists
13
www.luxoft.com
Pub/sub API
Overview
14
www.luxoft.com
Pub/sub API
The same file can be applied
• locally
• in k8s
Configuration
15
www.luxoft.com
Pub/sub API
Features
• Guarantees at-least-once semantics for message delivery
• Multiple subscribers with the same app ID
• Message delivered to one instance
• Multiple subscribers with different app ID
• Message delivered to all subscribers
• Topic scoping
• Limit which application can publish or subscribe to topics
• Messages are wrapped in CloudEvent format (if not already wrapped)
16
www.luxoft.com
Pub/sub API
Components
• Hazelcast
• Redis Streams (5.0.0 or later)
• NATS
• Kafka
• Azure Service Bus
• RabbitMQ
• Azure Event Hubs
• GCP Pub/Sub
• MQTT
• Possible to provide custom backend via SPI
17
www.luxoft.com
State management API
Overview
18
www.luxoft.com
State management API
Features
• Consistency
• eventual consistency (default behavior)
• strong consistency
• Concurrency
• first-write-wins (ETag support is required either by store or through Dapr emulation)
• last-write-wins
• Bulk operations
• not transactional
• transactional
19
www.luxoft.com
State management API
Components
Name CRUD
Transactional
(Supports Actors)
ETag
Aerospike ✅ ❌ ✅
Apache Cassandra ✅ ❌ ❌
Cloudstate ✅ ❌ ✅
Couchbase ✅ ❌ ✅
Hashicorp Consul ✅ ❌ ❌
Hazelcast ✅ ❌ ❌
Memcached ✅ ❌ ❌
MongoDB ✅ ✅ ❌
MySQL ✅ ✅ ✅
PostgreSQL ✅ ✅ ✅
Redis ✅ ✅ ✅
RethinkDB ✅ ✅ ✅
Zookeeper ✅ ❌ ✅
AWS, GCP, Azure stores…
20
www.luxoft.com
State management API
Components
• Dapr supports Redis 5 and later
• Azure supports Redis 4 and 6
21
www.luxoft.com
Bindings API
Overview
22
www.luxoft.com
Bindings API
Components
Name
Input
Binding
Output
Binding
Status
Apple Push Notifications (APN) ✅ Alpha
Cron (Scheduler) ✅ ✅ Alpha
HTTP ✅ GA
InfluxDB ✅ Alpha
Kafka ✅ ✅ Alpha
Kubernetes Events ✅ Alpha
MQTT ✅ ✅ Alpha
MySQL ✅ Alpha
PostgreSql ✅ Alpha
Postmark ✅ Alpha
RabbitMQ ✅ ✅ Alpha
Redis ✅ Alpha
SMTP ✅ Alpha
Twilio ✅ Alpha
Twitter ✅ ✅ Alpha
SendGrid ✅ Alpha
AWS, GCP, Azure, Alibaba…
23
www.luxoft.com
Secrets API
Overview
24
www.luxoft.com
Secrets API
Features
• Can be accessed
• Programmatically through API
• In Dapr component configuration files
• Secrets scoping
• By default, any secret is accessible from any Dapr application
• Each Dapr application can be configured to have access to only selected secrets
25
www.luxoft.com
Secrets API
Components
• Local environment variables
• Local file
• HashiCorp Vault
• Kubernetes secrets
• AWS Secret Manager
• GCP Secret Manager
• Azure Key Vault
26
www.luxoft.com
SDKs
Language Status Client SDK
Service
Extensions
Actor SDK
.NET Stable ✔
✔
ASP.NET Core
✔
Python Stable ✔
✔
gRPC
✔
FastAPI
Flask
Java Stable ✔
✔
Spring Boot
✔
Go Stable ✔ ✔
PHP Stable ✔ ✔ ✔
C++ In development ✔
Rust In development ✔
Javascript In development ✔
27
www.luxoft.com
Performance and scalability
Workflow
28
www.luxoft.com
Performance and scalability
Overhead
Test setup:
• 1,000 requests per second
• Sidecar limited to 0.5 vCPU
• Sidecar mTLS enabled
• Sidecar telemetry enabled (tracing with a sampling rate of 0.1)
• Payload of 1KB
• Dapr side car overhead (1,000 requests):
• 0.48 vCPU
• 23Mb
• Control plane consumes:
• In non-HA mode: 0.009 vCPU and 61.6 Mb
• In HA mode: ~0.02 vCPU and 185 Mb
29
www.luxoft.com
Performance and scalability
Latency
30
www.luxoft.com
Pros
 Simple workflows with pub/sub and stage management are easy to implement with Dapr
 No need to deal with different third-party SDK, drivers, etc.
 Encourages developers to use best practices
 Implementation of a component (store, pub-sub, etc) can be replaced easily
 Language-agnostic
 Well-documented
 API examples
 SDK examples
 Deployment examples
31
www.luxoft.com
Cons
 APIs provide a small subset of features of underlying components
 Restricts versions of underlying components
 Only Redis 5 and 6 are supported
 Makes it harder to launch/debug apps on the dev side
 Need to launch two processes instead of one (app + Dapr)
 Console log is cluttered
 No good support in IDE (yet?)
 Devs have to create launchers manually to launch Dapr
 Requires extra resources on server side (two-four pods)
 Adds complexity to the overall picture
 Overlaps with istio: mTLS, tracing
 Maturity status:
 A lot of components are in alpha/experimental state
 Low adaptation
32
www.luxoft.com
References
Good overview - https://www.youtube.com/watch?v=MjyulcRqh20
Examples - https://github.com/dapr/quickstarts
SDK examples - https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples
API reference - https://docs.dapr.io/reference/api/
Service Invocation Performance - https://docs.dapr.io/operations/performance-and-scalability/perf-service-invocation/
Thank You!
Eugene Bova "Dapr (Distributed Application Runtime) in a Microservices Architecture"
35
www.luxoft.com
Deployment in Kubernetes
Overview
36
www.luxoft.com
Deployment in Kubernetes
Annotations
37
www.luxoft.com
IDE support

More Related Content

Eugene Bova "Dapr (Distributed Application Runtime) in a Microservices Architecture"