Slide 1

Slide 1 text

Dapr as the Ultimate Microservices Patterns Framework Bilgin Ibryam Product Manager, Diagrid

Slide 2

Slide 2 text

Who is Bilgin Ibryam? ● Product Manager at Diagrid ● Former Architect at Red Hat ● Former Committer at Apache Camel ● A Dapr enthusiast ● Blogger and Author ○ Camel Design Patterns ○ Kubernetes Patterns @bibryam https://k8spatterns.io

Slide 3

Slide 3 text

Agenda Design Patterns Microservices Patterns Enterprise Integration Patterns Workflow Patterns Dapr APIs and Deployment Models

Slide 4

Slide 4 text

Patterns

Slide 5

Slide 5 text

Origins of Design Patterns A Pattern Language, Christopher Alexander et. al, 1977, pp. 21

Slide 6

Slide 6 text

Domain-Specific Patterns

Slide 7

Slide 7 text

Technology-Specific Patterns

Slide 8

Slide 8 text

Microservices Benefits Team autonomy Fast deployment Technology flexibility Failure isolation Scalability and availability

Slide 9

Slide 9 text

Microservices Challenges Inter-service interactions Network resiliency Data consistency Increased attack surface Technology sprawl Version management

Slide 10

Slide 10 text

How can Patterns Help? https://microservices.io/

Slide 11

Slide 11 text

Don’t Reinvent the Patterns

Slide 12

Slide 12 text

Dapr

Slide 13

Slide 13 text

What is Dapr? App A App B App C

Slide 14

Slide 14 text

Dapr Overview App HTTP/gRPC

Slide 15

Slide 15 text

Microservices Challenges Shipping Gateway Storage Storage Storage Message broker Front-end Inventory Shopping cart Checkout Payment Shipping Notifications Create new Service Create new Service Create new services

Slide 16

Slide 16 text

Service Template

Slide 17

Slide 17 text

Service Template Benefits Minimizing initial development overhead for new services Ensure consistent build logic Standardizing cross-cutting concerns

Slide 18

Slide 18 text

Service Template with Dapr @Topic(name = "orders", pubsubName = "orderpubsub") @PostMapping(path = "/orders", consumes = MediaType.ALL_VALUE) public Mono checkout(@RequestBody CloudEvent ce) { return Mono.fromSupplier(() -> { try { logger.info(cloudEvent.getData().getOrderId()); return ResponseEntity.ok("SUCCESS"); } catch (Exception e) { throw new RuntimeException(e); } }); } dependencies { ... // Dapr's core SDK with all features, except Actors. compile('io.dapr:dapr-sdk:1.10.0') // Dapr's SDK for Actors (optional). compile('io.dapr:dapr-sdk-actors:1.10.0') // Dapr's SDK integration with SpringBoot (optional). compile('io.dapr:dapr-sdk-springboot:1.10.0') } annotations: dapr.io/enabled: "true" dapr.io/app-id: "nodeapp" dapr.io/app-port: "3000" dapr.io/config: "tracing"

Slide 19

Slide 19 text

Service Chassis Cross-cutting concerns Configurations and secrets Logging Metrics Health checks Service discovery Asynchronous calls Workflows Data access

Slide 20

Slide 20 text

Approaches for Service Chassis Compute-only Language-specific Plumbing drift

Slide 21

Slide 21 text

Service Chassis with Dapr Runtime Sync calls Async calls Workflows Data Access Scheduling Resiliency Configs Observability Spring Quarkus Micro, Go kit Express.js Django .Net gRPC client REST client Netflix Eureka Consul Istio LinkerD Apache Kafka RabbitMQ Redis Streams NATs Apache Airflow Cadence Temporal Netflix Conductor Hibernate Drizzle jDBCTemplate Redis client Quartz Shedlock EventBridge Scheduler Hystrix Resilience4j Polly Failsafe Polly-js Consul Vault Open Telemetry Log4j Fluentd Jaeger Prometheus Zipkin Dapr Dapr Dapr Dapr Dapr Dapr Dapr Dapr Cross-cutting concerns

Slide 22

Slide 22 text

Microservices Challenges Shipping Gateway Storage Storage Storage Message broker Front-end Inventory Shopping cart Checkout Payment Shipping Notifications Resiliency Synchronous calls Observability Discovery Access control

Slide 23

Slide 23 text

Service Discovery on Kubernetes Node Port Load Balancer Ingress

Slide 24

Slide 24 text

Service Discovery on Kubernetes Manual Service Discovery Internal Service Discovery Limitations No resiliency: retries, circuit breakers, timeouts; No tracing and metrics No traffic encryption Service discovery limited to the cluster

Slide 25

Slide 25 text

Dapr Service Invocation

Slide 26

Slide 26 text

Service Invocation Shopping cart Checkout POST http://localhost:3500/v1.0/invoke/checkout/method/order POST http://localhost:5100/order

Slide 27

Slide 27 text

Service Invocation POST http://localhost:3500/v1.0/invoke/checkout/method/order POST http://localhost:5100/order Shopping cart Checkout DNS Service discovery Access Control Resiliency mTLS encryption Observability token authentication token authentication

Slide 28

Slide 28 text

Patterns included Remote Procedure Invocation Client-side discovery Server-side discovery Circuit breaker Access token Health check API Distributed Tracing Application metrics(network) Application logging (network) ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ Dapr Service Invocation

Slide 29

Slide 29 text

Microservices Challenges Shipping Gateway Storage Storage Storage Message broker Front-end Inventory Shopping cart Checkout Payment Shipping Notifications Asynchronous calls Publish Subscribe

Slide 30

Slide 30 text

Dapr Publish Subscribe

Slide 31

Slide 31 text

Publish Subscribe Checkout Shipping Message broker POST http://localhost:3500/v1.0/publish/mybroker/order-messages POST http://localhost:5100/orders

Slide 32

Slide 32 text

Publish Subscribe POST http://localhost:3500/v1.0/publish/mybroker/order-messages POST http://localhost:5100/orders Checkout Shipping Observability backend Message broker Cloudevents Access Control Resiliency token authentication token authentication Encryption

Slide 33

Slide 33 text

Patterns Included Message Expiration Dead Letter Channel Guaranteed Delivery Content Based Router Message Filter Aggregator/Splitter Service Activator Messaging Gateway https://www.enterpriseintegrationpatterns.com/ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ Dapr Pub/Sub API

Slide 34

Slide 34 text

Microservices Challenges Shipping Gateway Storage Storage Storage Message broker Front-end Inventory Shopping cart Checkout Payment Shipping Notifications Stateful Orchestration How do I orchestrate business transactions?

Slide 35

Slide 35 text

Dapr Workflow

Slide 36

Slide 36 text

Workflow Example End Activity A Get secret Wait for event External Event Activity D Publish message Start Receive message Store event result Activity C Activity B Invoke an API

Slide 37

Slide 37 text

End Activity A Activity B Activity C Start End Activity A Activity B Activity C Start Activity CreateTimer Continue As New Start Wait with further execution Restart the workflow Wait for event Approval Event End Get Approval Not Approved Start Approved Sequence Split/Synchronize Timer External trigger https://www.diagrid.io/blog/in-depth-guide-to-dapr-workflow-patterns

Slide 38

Slide 38 text

Choreography or Orchestration? https://www.diagrid.io/blog/choreography-or-orchestration-that-is-the-wrong-question/

Slide 39

Slide 39 text

More?

Slide 40

Slide 40 text

Microservices Challenges Shipping Gateway Storage Storage Storage Message broker Front-end Inventory Shopping cart Checkout Payment Shipping Notifications How do I implement first-write-wins? How do I connect to 3rd party systems? How do I emit data changes (Outbox)? How do I encrypt data before storing? How do I ensure exclusive access to a resource (Lock)?

Slide 41

Slide 41 text

Bindings API for bi-directional connection to 3rd-party systems Distributed Lock API for exclusive access to a resource (singleton) Configuration API for dynamic application configuration Secrets API for integrating with secret stores Transactional Outbox Pattern for emitting state change notifications Crypto API for encrypting and decrypting messages Other Dapr APIs

Slide 42

Slide 42 text

Dapr on VM Dapr on Kubernetes Serverless Dapr https://www.diagrid.io/blog/dapr-deployment-models Dapr Deployment Models https://www.diagrid.io/catalyst https://www.diagrid.io/conductor Serverless Dapr APIs for Messaging, Data, and Workflow Put Dapr on Kubernetes on autopilot

Slide 43

Slide 43 text

Closing Thoughts Developing distributed systems is hard. Patterns provide a framework to learn, navigate, and communicate within this vast problem space. Dapr is the ultimate toolkit for developing microservices, adaptable across languages, platforms, Kubernetes, and serverless.

Slide 44

Slide 44 text

Resources https://www.diagrid.ws/webinars @bibryam dapr.io https://www.diagrid.io/conductor @diagridio https://www.diagrid.io/catalyst https://www.diagrid.ws/stateofdaprreport

Slide 45

Slide 45 text

Q and A