Moaid Hathot Software Architect Moaid.hathot@outlook.com @MoaidHathot https://moaid.codes https://meetup.com/Code-Digest Dapr: Distributed Application Runtime
Microservices More and more applications are being developed as distributed applications 2
Microservices  Modularity  Loose service coupling  Service-independent deployments  Better scalability  Better reliability  Multiple stacks 3
Microservices – price tag  Concurrency issues  Failure handling  Retry policies  State management  Distributed tracing  Deployment 4
Microservices – price tag Less time to develop business logic 5
Microservices – price tag 6
About Moaid Hathot 7 Moaid Hathot  Software Architect & Code Jedi @ CodeValue  Software Craftsmanship advocate  Clean Coder  Co-Founder of Code.Digest();  OzCode Evangelist
Microservices – solutions  Serverless architecture  Azure Functions & AWS Lambada  Stateless, event-driven microservices  Virtual Actor model  Object-oriented microservices  E.g Microsoft Orleans  The cloud takes care of  Activating, retries, scaling, failure handling 8
Microservices – solution issues  Coupled to Stack  Coupled to cloud providers  A single application depends on multiple SDKs  FaaS and Actor integration can be complicated  FaaS runtimes can be heavy 9
Dapr Distributed Application Runtime 10
Dapr  Portable, Event-driven runtime for building microservices  Open Source  https://github.com/dapr/dapr  7K Github stars  129 contributors  28+ new components since launch  Alpha phase 11
Dapr  Supports any platform  Services knows only HTTP/gRPC  Can decide to use dedicated SDKs  Services are not aware of the actual technologies  Services are not aware of other services  Everything is configurable via yaml file  E.g you can switch from Cosmos DB to DynamoDB 12
Dapr  Sidecar architecture  Dapr is isolated via Process or Container from your app  Two hosting modes  Self hosting  Kubernetes 13
Dapr – self hosting 14
Dapr – self hosting 15
Dapr – self hosting 16 HTTP/gRPC
Dapr – Kubernetes 17 HTTP/gRPC
Dapr – Kubernetes 18 HTTP/gRPC Container Container
Dapr – Kubernetes 19 HTTP/gRPC Container Container Pod
Dapr 20 Image Source
Dapr – building blocks 21 Image Source
Dapr – building blocks 22 Image Source
Dapr – building blocks 23 Image Source
Dapr – building blocks 24 Image Source
Dapr – building blocks 25 Image Source
Dapr – building blocks 26 Image Source
Dapr – building blocks 27 Image Source
Dapr – building blocks 28 Image Source
Dapr – Service Invocation  Every service has an id (name)  Calling services has to know that id  HTTP or gRPC  Takes care of  Discoverability  Reliability  Retries  Failure handling 30
Dapr – Service Invocation 31 Image Source
Dapr – Service Invocation 32 Image Source
Dapr – Service Invocation 33 Image Source
Dapr – Service Invocation 34 Image Source
Dapr – Service Invocation 35 Image Source
Dapr – Service Invocation 36 Image Source
Dapr – Service Invocation 37 Image Source
Demo  Run Dapr  Service Invocation 39
Dapr – State Management  The actual store is not known to services  Support for many platforms, including:  Redis  AWS DynamoDB  Azure Cosmos DB  MongoDB  Cassandra  SQL Server  More…  Easy to implement new state store 40
Dapr – State Management 41 Image Source
Dapr – State Management 42 Image Source
Dapr – State Management 43 Image Source
Dapr – State Management 44 Image Source
Dapr – State Management 45 Image Source
Dapr – State Management 46 Image Source
Dapr - Secrets  Provides an API for retrieving secrets  Supports  Azure KeyVault  AWS Secret Manager  GCP Cloud KMS  GCP Secret Manager  Kubernetes  Hashicorp Vault  More…  Easy to implement new secret stores 47
Dapr – Secrets 48 Image Source
Demo  State Management  Redis  CosmosDB  Secret Store  Azure KeyVault 49
Dapr – Pub/Sub  Publish/subscribe pattern  Used for decoupling services  Producer send messages to a topic  Consumers receives messages from a topic  Dapr APIs provides at-least-once guarantees  Supports multiple brokers  Kafka  RabbitMQ  Redis Streams  Azure Event Hubs  More… 50
Dapr – Pub/Sub 51 Image Source
Dapr – Pub/Sub 52 Image Source
Dapr – Pub/Sub 53 Image Source
Dapr – Pub/Sub 54 Image Source
Dapr – Pub/Sub 55 Image Source
Demo  Pub/Sub 56
Dapr – Resource Bindings  Input/Output with cloud resources  Similar in concepts to Azure Function’s Binding  Trigger your service or invoke external systems  Takes care of connections, polling, queuing, etc…  Benefits  Focus on Business logic  Your code is free from SDKs and libraries  Auto handling for retries & failure recovery  Switch bindings at run time  Deploy to different environments without code changes 57
Dapr – Resource Bindings  Inputs (partial list)  Kafka  RabbitMQ  AWS Kinesis  AWS SQS  GCP Cloud Pub/Sub  Azure EventHubs  Azure SignalR Service  Azure Service Bus Queues  More… 58
Dapr – Resource Bindings  Outputs (partial list)  Kafka  RabbitMQ  AWS Kinesis  AWS DynamoDB  GCP Cloud Pub/Sub  GCP Storage Bucket  Azure EventHubs  Azure SignalR Service  More… 59
Dapr – Resource Bindings 60
Dapr – Resource Bindings 61
Dapr – Resource Bindings 62 Cosmos DB DynamoDB Event Hubs
Demo  Bindings  SignalR Binding 63
Dapr – Observability  Monitor the Dapr system services  Including interaction and behaviors  Integrates with OpenTelemetry  Supports  Azure Monitor  Azure ApplicationInsights  Elastic Search  Zipkin  More… 64
Dapr – Observability  Metrics  Latency, traffic failures, error rate, CPU usage, etc…  Logs  Traces, errors, etc…  Each trace contains hostname, component name and id, more…  Distributed Tracing  Debugging and monitoring distributed flows  W3C tracing  Health  Determine health via HTTP endpoint 65
Dapr - Dashboard  Web-based UI for Dapr  View information, logs, etc…  Support both locally and Kubernetes sidecars  Can stop running sidecars (Self hosted)  View sidecars logs 66
Dapr - Dashboard 67 Image Source More Info
Demo  Observability 68
Dapr – Virtual Actors  The Actor Model  Self-contained unit of code (actor)  Actors interacts using via messages  The runtime manages how, when and where each actor runs  Dapr implements the Virtual Actors Model  Takes care of  Lifetime  Retries  Failover  Concurrency 69
summary  Microservices has many benefits  But also challenges  Dapr  Runtime for building microservices  Any platform, any stack, any environment  Takes care of a lot of the challenges  Open Source  Community  Demo repo:  https://github.com/MoaidHathot/Architecture-next-2020-dapr 70
Q A 71
Moaid Hathot Software Architect moaid.hathot@outlook.com @MoaidHathot https://moaid.codes https://meetup.com/Code-Digest

Dapr: distributed application runtime