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

Leveraging the power of Reactive Architectures

Leveraging the power of Reactive Architectures

Microservices, Reactive, and Distributed Systems Vienna

SQUER Solutions

August 24, 2021
Tweet

More Decks by SQUER Solutions

Other Decks in Technology

Transcript

  1. Leveraging the
    power of Reactive
    Architectures
    Microservices, Reactive and Distributed Systems Vienna
    Vienna, August 2021

    View Slide

  2. @duffleit
    @duffleit
    [email protected]
    David Leitner
    Coding Architect

    View Slide

  3. Reactive?
    Programming with, or designing upon,
    asynchronous data streams.

    View Slide

  4. asynchronous data streams.
    Space
    Time
    Collections
    Iterator Generator
    Value
    Getter Setter
    Promise
    Deferred Resolver
    Stream
    Reader Emitter

    View Slide

  5. The relationship between them is implicit, an idea that only exists in the
    mind of the programmers. It should be explicit, a part of the language,
    and existing for all time. Counter and doubled should be bound.

    View Slide

  6. the Destiny Operator
    paulstovell.com/reactive-programming

    View Slide

  7. 1
    map(x => x*2) 2
    3
    6
    Reactive Programming,
    is Programming with Streams.

    View Slide

  8. View Slide

  9. View Slide

  10. C’mon, show me a
    down-to-earth
    example.

    View Slide

  11. YAMS — Yet Another Mail Service
    NEW 2021-04-11 — An important Email
    2021-04-09 — Another important Email
    2021-04-08 — Do you want to join my network?
    2021-04-05 — Nigerian prince wants to send you money
    X
    your inbox contains 4 mails
    1 NEW Mail
    Reload
    Controller
    Rest Client
    update UI Element
    update UI
    update UI

    View Slide

  12. YAMS — Yet Another Mail Service
    NEW 2021-04-11 — An important Email
    2021-04-09 — Another important Email
    2021-04-08 — Do you want to join my network?
    2021-04-05 — Nigerian prince wants to send you money
    X
    your inbox contains 4 mails
    1 NEW Mail
    Reload Websocket Client
    Email Email
    count()
    count()
    collect()
    filter()
    subscribe
    Email
    map()

    View Slide

  13. YAMS — Yet Another Mail Service
    NEW 2021-04-11 — Hello Reactive Systems Vienna! 👋
    2021-04-09 — Another important Email
    2021-04-08 — Do you want to join my network?
    2021-04-05 — Nigerian prince wants to send you money
    X
    your inbox contains 5 mails
    2 NEW Mail
    Websocket Client
    Email Email
    count()
    count()
    collect()
    filter()
    subscribe
    Email
    NEW 2021-04-11 — An important Email
    map()

    View Slide

  14. We move from a
    pull-based design,
    to an asynchronous
    push-based design.

    View Slide

  15. Reactive Programming
    Reactive Architectures
    We take the same concepts from reactive programming
    and move them up to the system architecture.

    View Slide

  16. “The Universal BBC Architecture”
    Back in 2010…
    Allard Buijze
    Box Cylinder
    Box

    View Slide

  17. Internet has 4.7 Billion users.
    Facbook has 2.8 Billion users.
    Youtube has 2.1 Billion users.
    2010
    2020
    The Internet has 1.4 Billion users.
    A single website may
    now handle twice as
    much traffic as the entire
    internet a decade ago.

    View Slide

  18. View Slide

  19. The Reactive Manifesto
    Message
    Driven
    Responsive
    Elastic Resilient
    NFR
    Supported by
    Enabled by
    Scalability Extendibility

    View Slide

  20. Microservice A
    Microservice B
    Message
    Driven
    Responsive
    Elastic Resilient
    Value
    Form
    Means

    View Slide

  21. Microservice A
    Microservice B
    Message
    Driven
    Responsive
    Elastic Resilient
    Value
    Form
    Means
    Microservice B
    Microservice B

    View Slide

  22. Microservice A
    Microservice B
    Message
    Driven
    Responsive
    Elastic Resilient
    Value
    Form
    Means
    Microservice B
    Stream

    View Slide

  23. Microservice A
    Microservice B
    Message
    Driven
    Responsive
    Elastic Resilient
    Value
    Form
    Means
    requests pile up

    View Slide

  24. Message
    Driven
    Responsive
    Elastic Resilient
    Value
    Form
    Means
    Microservice A
    Stream
    Microservice B

    View Slide

  25. We support
    Back-Pressure Stream
    Provider Consumer
    events are stored
    until consumed
    Stream
    Provider Consumer A
    Consumer C
    Consumer B
    scaling out
    consumers
    We can horizontally scale by
    Location Transparency

    View Slide

  26. We move from a
    synchronous pull-based
    architecture, to an
    asynchronous push-based
    architecture.

    View Slide

  27. Push, Pull,
    Whaaaaaat?

    View Slide

  28. Microservice A
    Microservice B
    Microservice C
    Web Application

    View Slide

  29. Microservice A
    Microservice B
    Microservice C
    Web Application
    Microservice C
    with high latency
    First Generation
    Integrated Synchronous
    without Backpressure Support

    View Slide

  30. Microservice A
    Microservice B
    Microservice C
    Web Application
    Microservice C
    with high latency
    Second Generation
    Partially Asynchronous &
    Backpressure Support
    Queue
    isolates bottleneck
    Queue

    View Slide

  31. Web Application
    Stream
    Microservice
    usually Backend-For-Frontend (BFF)
    Microservice A
    Microservice B
    Microservice C
    Thirds Generation
    Stream Centric and
    Fully Asynchronous

    View Slide

  32. Events as the System State
    Stream of Transactions
    Max sent Tim 100€ Max sent Maria 70€ Tim sent Maria 25€

    Current Balance
    Max
    - 100€
    Tim
    + 100€
    Maria
    + 70€
    - 170€ + 75€ + 95€
    Stream-table duality

    View Slide

  33. Web Application
    Stream
    Microservice
    usually Backend-For-Frontend (BFF)
    Microservice A
    Microservice B
    Microservice C
    Migration via
    Change-Data-Capture
    Legacy
    Database New User Added
    User Updated
    Change-Data-Capture
    DB Log

    View Slide

  34. www.squer.link/migration-strategies

    View Slide

  35. Events as the System State
    Stream of Transactions
    Max sent David 100€ Max sent Maria 70€ David sent Maria 25€
    Current Balance
    Max
    - 100€
    David
    + 100€
    Maria
    + 70€
    - 170€ + 75€ + 95€
    Stream-table duality
    the truth,
    the whole truth,
    nothing but the truth.
    Event Souring

    View Slide

  36. Web Application
    Stream
    Microservice
    usually Backend-For-Frontend (BFF)
    Microservice A
    Microservice B
    Microservice C
    Thirds Generation
    Stream Centric and
    Fully Asynchronous

    View Slide

  37. Web Application
    Eventstore
    Microservice
    usually Backend-For-Frontend (BFF)
    Microservice A
    Microservice B
    Microservice C
    Thirds Generation
    Stream Centric and
    Fully Asynchronous

    View Slide

  38. Web Application
    Eventstore
    Microservice
    usually Backend-For-Frontend (BFF)
    Lambda A
    Lambda B
    Lambda C
    Thirds Generation
    Stream Centric and
    Fully Asynchronous

    View Slide

  39. Web Application
    Stream
    Microservice
    usually Backend-For-Frontend (BFF)
    Microservice A
    Microservice B
    Microservice C
    Thirds Generation
    Stream Centric and
    Fully Asynchronous

    View Slide

  40. Stream Centric Systems
    are the only way to build
    autonomous Microservices.

    View Slide

  41. by: twitter.com/swardley

    View Slide

  42. Stream Centric Systems
    are the only way to build
    autonomous Microservices.

    View Slide

  43. Microservice A
    Microservice B
    Microservice C
    UI

    View Slide

  44. Account Summary Service
    Transaction Service
    User Service
    Web Banking
    Categorization Service
    Config Service
    The rise of the
    Entity Service
    Antipattern
    High Presure
    Low Resilience
    Z
    Y
    X
    Payment Service

    View Slide

  45. Account Summary Journey
    Transaction Service
    User Service
    Web Banking
    Categorization Service
    Config Service
    The rise of the
    Entity Service
    Antipattern
    High Presure
    Low Resilience
    Z
    Y
    X
    Payment Journey
    Paymet Customer Journeys
    Account Overview Customer Journeys
    Low service Autonomy
    Weak Independent Deployability
    Weak Independent Scalability

    View Slide

  46. Account Summary Journey
    Transaction Service
    User Service
    Web Banking
    Categorization Service
    Config Service
    Payment Journey
    projection
    projection
    We never write to projections,
    we only read from them.
    CQRS in a nutshell
    websockets
    Strong Service Autonomy at Runtime
    Smaller Deployment Footprint
    Good Horizontal Scalability
    Account Summary Journey
    projection

    View Slide

  47. Lambda A
    Web Application
    Lambda B
    Lambda C
    Stream
    GraphQL
    Microservice A
    Microservice B
    Microservice C
    Web Application

    pull-based push-based

    View Slide

  48. www.squer.at

    View Slide

  49. Focus on Realtime Integration
    Insurance
    Calculation

    View Slide

  50. GraphQL
    Step 1 Step 2 Step 2
    Car Brand
    Build Year
    Car Model
    Insurance Agent
    Customer
    ✅ This Is Correct
    Alfa Romeo Giulia, 2020
    110PS, Diesel
    Products
    Users
    Configurations
    Eventstore
    GraphQL
    car brand has changed
    Alfa Romeo
    2020
    Giulia, 110PS

    View Slide

  51. GraphQL
    Step 1 Step 2 Step 2
    Car Brand
    Build Year
    Car Model
    Insurance Agent
    Alfa Romoe
    2020
    Giulia, 110PS
    Customer
    ✅ This Is Correct
    Alfa Romeo Giulia, 2020
    110PS, Diesel
    Step 1 Step 2 Step 2
    Coverage
    200 €
    🏁 Sign Digital
    Do you accept 70% coverage
    for 200€?
    Products
    Users
    Configurations
    Eventstore
    GraphQL

    View Slide

  52. GraphQL
    Step 1 Step 2 Step 2
    Car Brand
    Build Year
    Car Model
    Insurance Agent
    Customer
    ✅ This Is Correct
    Alfra Romeo Giulia, 2020
    110PS, Diesel
    Step 1 Step 2 Step 2
    Coverage
    250 €
    🏁 Sign Digital
    Do you accept 90% coverage
    for 250€?
    Products
    Users
    Configurations
    Eventstore
    GraphQL
    Customers expect
    realtime syncronisation
    between channels.

    View Slide

  53. Focus on Resilience
    High
    Available
    Banking

    View Slide

  54. Mobile Banking Usage
    Show balance & last transactions: 93%
    Initiate new payment: 3%
    Any other functionality: 4%

    View Slide

  55. Transactions
    Web Banking
    Users
    Accounts
    Stream
    GraphQL
    Projection
    Projections
    1⃣ Projections act as read-models for a specific client.
    2⃣ They subscribe to events & hydrate the projection.
    3⃣ The client only reads from the projection.

    View Slide

  56. Transactions
    Web Banking
    Users
    Accounts
    Stream
    GraphQL
    Projection
    Projections
    1⃣ Projections act as read-models for a specific client.
    2⃣ They subscribe to events & hydrate the projection.
    3⃣ The client only reads from the projection.
    Projection

    View Slide

  57. GraphQL
    Mobile Client
    Projection
    Transactions
    Web Banking
    Users
    Accounts
    Stream
    GraphQL
    Projection
    Projections
    1⃣ Projections act as read-models for a specific client.
    2⃣ They subscribe to events & hydrate the projection.
    3⃣ The client only reads from the projection.
    Only one hard problem in
    computer science left. 😎
    Projection
    Show balance & last transactions working,
    93% of customers still happy.
    With a concept like
    optimistic UIs even more.

    View Slide

  58. lousy memes
    Ok let‘s
    sum up!
    lousy memes
    within lousy
    memes
    High Resilience &
    Scalability

    View Slide

  59. Architectural Styles always
    buy you options.
    This stuff is cool,
    Reactive Architectures buy you Resilience,
    Realtime Capabilities, Elasticity, & Extendibility.
    you pay by complexity.
    💵
    e.g. perpetual, or eventual inconsistency

    View Slide

  60. Maybe start small,
    and shift to reactive systems once needed.

    View Slide

  61. by: twitter.com/swardley

    View Slide

  62. @duffleit
    @duffleit
    [email protected]
    David Leitner
    Coding Architect
    squer.at/slides
    this presentation

    View Slide

  63. @duffleit

    View Slide