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

Reliable communication - outbox pattern - PHPers Summit 2023

Reliable communication - outbox pattern - PHPers Summit 2023

Using an outbox pattern, I will show you how to make reliable communication between services. The presentation will also have a demo with an implementation of the pattern.

Feedback form: https://joind.in/event/phpers-summit-2023/reliable-communication---outbox-pattern

Damian Dziaduch

May 27, 2023
Tweet

More Decks by Damian Dziaduch

Other Decks in Programming

Transcript

  1. “Heya, I’m Dominik, the software engineer @ The Best Software

    Company. We have one big project that have some problems” Dominik The Best Software Company Damian Dziaduch - Reliable communication - PHPers Summit 2023
  2. The Best Software Company Damian Dziaduch - Reliable communication -

    PHPers Summit 2023 - Typical company - Huge monolith - Big ball of mud architecture - Features are taking longer and longer - More and more bugs
  3. “We read few books about micro services, we have decided

    that we are going fully into micro services.” Dominik The Best Software Company Damian Dziaduch - Reliable communication - PHPers Summit 2023
  4. Step 3 Network as a spine Step 4 Problems? Step

    2 Microservices Damian Dziaduch - Reliable communication - PHPers Summit 2023 The path Step 1 Monolith
  5. “The data is stored and the event is sent. Both

    must succeed. All or nothing.” Dominik The Best Software Company Damian Dziaduch - Reliable communication - PHPers Summit 2023
  6. > Applies to the event producers > Atomicity - all

    or nothing > Simple command handlers > Sending events is decoupled > Faster command handlers > No event is sent, just stored > Infinite retries > History of sent events Damian Dziaduch - Reliable communication - PHPers Summit 2023 Outbox - benefits
  7. > At least once delivery > Receivers must be ready

    for this > Inbox pattern for the rescue > A relay is required > Periodically pools events from the outbox > Use log tailing to retrieve events > NoSQL solution is more complex > Complex indexing > Complex querying Damian Dziaduch - Reliable communication - PHPers Summit 2023 Outbox - drawbacks
  8. > Your code is doing critical business logic (core domain)

    > The event broker is not reliable Damian Dziaduch - Reliable communication - PHPers Summit 2023 Outbox - when to use it
  9. > Applies only to the event consumers > Event must

    have unique ID > Event must be stored > They could be stored forever or for some time > Not needed when your application is already idempotent > Product can be created once > Once it is created, next tries will be discarded > History of received events Damian Dziaduch - Reliable communication - PHPers Summit 2023 Inbox summary
  10. > Outbox > Atomicity - all or nothing > At

    least once delivery > Infinite retries > History of sent event > Inbox > Guarantees that event is processed only once > History of processed events Damian Dziaduch - Reliable communication - PHPers Summit 2023 Summary
  11. > Remote work > Flexible work day > Stock options

    > Learning budget > Well-being budget > Paid days off for contractors > MacBooks Damian Dziaduch - Reliable communication - PHPers Summit 2023 We are hiring! jobs.printify.com