Dapr Overview
Dapr Overview
Internet
CosmosDB
Frontend service Cart service Checkout service
Http
Kafka message
Shipping service
Why Dapr?
Stateful microservices are hard especially store Simple state management using key/value pairs with
configuration, consistency and concurrency pluggable state stores
Events from any external system need to trigger a Open component model enables bindings to be
service developed for any external system to send events
Publishing and subscribing to events is dependent on Standard API with pluggable providers makes the
compiling with specific libraries code portable for sending and receiving events
© Microsoft Corporation
Introducing Dapr
A portable, event-driven, serverless runtime for building
distributed applications across cloud and edge
Standard APIs accessed over http/gRPC protocols from user service code
e.g. http://localhost:3500/v1.0/invoke/myapp/method/neworder
Dapr runs as local “side-car library” dynamically loaded at runtime for each service
Service-to-service State
invocation management
Application
code API Resource
Actors
bindings & triggers
Any code or
.NET Core Functions
framework…
HTTP/gRPC APIs
Service-to- Resource
State Publish and Distributed
service bindings & Actors Extensible…
management subscribe tracing
invocation triggers
Resource bindings
Scanning for events
Application
Messaging
Publish and
subscribe
Load and
save state
State stores
Dapr Kubernetes-hosted
Deploys and
manages Dapr
Components
Pod Pod Pod
CONTAINER CONTAINER CONTAINER Component
Input/output bindings
management
State stores
CONTAINER Pod CONTAINER
Dapr API
HTTP or gRPC Service code
Sidecar
Publish and
Use components subscribe
{
"name": "Tatooine"
} key Value
myApp-weapon "DeathStar"
App myApp-planet {
“myApp” "name": "Tatooine"
POST }
http://localhost:3500/v1.0/state
State store of your choice
[{
"key": "weapon",
"value": "DeathStar"
}, {
"key": "planet",
"value": {
"name": "Tatooine"
}
}]
Service Invocation
POST
http://localhost:3500/v1.0/invoke/cart/method/checkout
{
"user":"johndoe",
"cart":"0001"
}
“frontend”
“cart”
POST
http://10.0.0.2:8000/checkout
{
"user":"johndoe",
"cart":"0001"
}
DEMO
Dapr Invocation and
State Management
-- Redis
-- Cosmos
Output bindings
Redis
Event Hubs
Event
CosmosDB
Kafka
Redis
Hubs
SQS
DynamoDB
App
POST
http://localhost:3500/v1.0/bindings/inventory
{ CosmosDB
"data":
{
"sku":"v100",
"quantity":"50"
}
} Kafka
SQS
Input bindings
GET/POST
http://localhost:8000/trigger
Redis
{
"user":"johndoe"
}
Event Hubs
Event Kafka
Redis
Hubs
SQS
App
Kafka
SQS
Resource Bindings
Dapr enable events to be sent and received from specific resources for any cloud
provider
Examples: Azure EventHubs, AWS SNS, Google storage
Publishing & Subscribing
POST
http://10.0.0.4:8004/order
POST
http://localhost:3500/v1.0/publish/ “email”
"topic":"order",
"data":{
"user":"johndoe",
"item":"ZeroDay" "data":{
}, POST "user":"johndoe",
http://10.0.0.5:8005/order "item":"ZeroDay"
}
“cart” “shipping”
Publish Subscribe
Actors
Actor pattern is good for solutions involving small, independent units of state and logic
Actor runtime which provides concurrency, activation, deactivation, timers, reminders,
and partitioning
Standard API
http://localhost:3500/v1.0/actors/<actorType>/<actorId>/method/<method>
Invoke the ProcessData method on myactor with id=50, providing the value 5
Virtual Actors
with Dapr Video Game
Enemy
Stateful, objects of
storage and compute
Host/Pod
Dapr Actor Features:
• Distribution & failover
• Turn-based concurrency
• State management
• Timers
• Reminders
Host/Pod
Virtual Actors with Dapr POST
http://10.0.0.6:6004/update
Pod X
{ Actor A
“speed":“1"
}
POST
http://localhost:3500/v1.0/actors/MyActors/A/method/update Actor B
{
“speed":“1"
}
Invoke
Actor Pod Y
App
Actor C
Get Actor
Location Actor D
Placement
Service
Virtual Actors with Dapr Pod X
Actor A
POST
http://localhost:3500/v1.0/actors/MyActors/C/method/updateName Actor B
{
“speed":“3"
}
Invoke
Actor Pod Y
App
Actor C
Allocate
POST
http://10.0.0.7:6005/update
Get Actor
Location { Actor D
“speed":“3"
Placement }
Service
Dapr developer frameworks
Distributed Tracing & Diagnostics
Dapr Dapr
Tracing
Backend
Distributed Tracing and Diagnostics App Insights
Datadog
Instana
App
“frontend”
Jaeger
+App
Prometheus
many
Datadog
SignalFX
Insights
Instana
Jaeger
more
SignalFX
App Prometheus
“backend”
+ many more
Customer: Bosch IoT System Connector project
Learn more
https://github.com/dapr/dapr