Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Dapr as the Ultimate Microservices Patterns Framework

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. Dapr as the Ultimate
    Microservices Patterns
    Framework
    Bilgin Ibryam
    Product Manager, Diagrid

    View full-size slide

  2. 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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  5. Domain-Specific Patterns

    View full-size slide

  6. Technology-Specific Patterns

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  10. Don’t Reinvent the Patterns

    View full-size slide

  11. What is Dapr?
    App A
    App B
    App C

    View full-size slide

  12. Dapr Overview
    App
    HTTP/gRPC

    View full-size slide

  13. 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

    View full-size slide

  14. Service Template

    View full-size slide

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

    View full-size slide

  16. 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"

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  19. 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

    View full-size slide

  20. 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

    View full-size slide

  21. Service Discovery on Kubernetes
    Node Port Load Balancer Ingress

    View full-size slide

  22. 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

    View full-size slide

  23. Dapr Service Invocation

    View full-size slide

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

    View full-size slide

  25. 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

    View full-size slide

  26. 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

    View full-size slide

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

    View full-size slide

  28. Dapr Publish Subscribe

    View full-size slide

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

    View full-size slide

  30. 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

    View full-size slide

  31. 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

    View full-size slide

  32. 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?

    View full-size slide

  33. Dapr Workflow

    View full-size slide

  34. 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

    View full-size slide

  35. 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

    View full-size slide

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

    View full-size slide

  37. 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)?

    View full-size slide

  38. 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

    View full-size slide

  39. 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

    View full-size slide

  40. 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.

    View full-size slide

  41. 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

    View full-size slide