$30 off During Our Annual Pro Sale. View Details »

Dapr as the Ultimate Microservices Patterns Fra...

Dapr as the Ultimate Microservices Patterns Framework

In the realm of microservices architecture, there exists a vast array of patterns guiding developers. Dapr emerges as the ultimate polyglot framework, implementing many of these patterns, ensuring a streamlined and efficient application development across diverse platforms.

Bilgin Ibryam, Diagrid Product Manager and O'Reilly co-author of "Kubernetes Patterns" as he explains how Dapr implements modern microservice patterns.

Recording: https://www.youtube.com/watch?v=YEvcNMIqaFk

Bilgin Ibryam

February 02, 2024
Tweet

More Decks by Bilgin Ibryam

Other Decks in Programming

Transcript

  1. 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
  2. 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
  3. Service Template Benefits Minimizing initial development overhead for new services

    Ensure consistent build logic Standardizing cross-cutting concerns
  4. Service Template with Dapr @Topic(name = "orders", pubsubName = "orderpubsub")

    @PostMapping(path = "/orders", consumes = MediaType.ALL_VALUE) public Mono<ResponseEntity> checkout(@RequestBody CloudEvent<Order> 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"
  5. Service Chassis Cross-cutting concerns Configurations and secrets Logging Metrics Health

    checks Service discovery Asynchronous calls Workflows Data access
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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
  11. Microservices Challenges Shipping Gateway Storage Storage Storage Message broker Front-end

    Inventory Shopping cart Checkout Payment Shipping Notifications Asynchronous calls Publish Subscribe
  12. 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
  13. 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
  14. 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?
  15. 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
  16. 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
  17. 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)?
  18. 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
  19. 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
  20. 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.