The Microservice Takeover: “How low-code is modernizing applications”
In my previous post, we explored the advantages of event-driven architecture (EDA) and the pub/sub messaging pattern for building modern, scalable systems. If you haven't already, I recommend checking out that post for a deeper dive into this powerful messaging pattern.
Publish-Subscribe (pub/sub) for Asynchronous Communication
In this article, we'll dive deeper into the practical applications of the microservice approach with a real use case, focusing on the pub/sub messaging pattern for asynchronous communication.?
Scenario: “Monolithic Legacy Application”
XYZ Enterprises, a large company, relies on a monolithic legacy application for various business functions. This application follows a linear workflow:
This approach presents several challenges:
Solution: “The Pub/Sub Application”
Pub/Sub addresses the previously stated challenges by enabling vertical or horizontal scalability for individual consumers, decoupling services to reduce dependencies, and enhancing fault tolerance by isolating failures to specific functionalities.?
In this microservice approach, when an order is made, the Order service publishes an event that is routed to multiple consumers, allowing each service to act autonomously based on its logic, diverging from linear flow.
This diagram showcases the solution:
This means that whenever an order is made, it will:
领英推荐
This establishes a complete decoupling between each service, and because of the nature of the pub/sub pattern, each microservice can scale and fail independently. Additionally, since there are no single points of failure, error cascading is mitigated.
Plan for Failure
Even in robust architectures, unforeseen errors can arise. To address these errors, we will now explore how to implement a reprocessing pipeline to manage transient errors, preventing them from disrupting the overall workflow.
Consider a scenario where the "Order service” triggers an event of an order made. The flow will proceed as follows:
The Reprocessing Pipeline for Transient Errors
This process involves the following steps:
Why Retries Matter
Imagine a scenario where an order is placed, therefore, triggering a sequence of events. However, due to a network glitch, the "Inventory service" encounters an error while updating the stock levels. In this context, the reprocessing pipeline (functioning periodically as a scheduler), retrieves the failed event(s) for reprocessing.
However, if a system is already overloaded and experiencing timeouts, retries may exacerbate the situation. Each retry adds to the system's burden potentially causing more issues.
To mitigate these challenges, we can adopt various approaches. For example, initiating retries only when the dependent system is healthy and likely to respond successfully. This opens up a new topic, which is how to integrate the Circuit Breaker pattern for error handling into your workflows. This topic will be covered in upcoming articles.
Conclusion
Pub/Sub's role in modern architecture includes multiple benefits as already mentioned. Primarily, it decouples publishers and subscribers, enabling asynchronous and fault-tolerant message handling. Reprocessing strategies enhance this messaging pattern by retrying failed messages due to transient errors, improving system reliability.
Thank you for reading and keep an eye out for upcoming articles!
Onboarding & Documentation Manager @Digibee
5 个月Another high-quality article with applied knowledge on the potential of event-driven architecture! Loved the read, Martin E.! Kudos!!
Enablement Tech Lead at Digibee | Integration Analyst | AWS CCP | GCP CDL | Fullstack Developer | Finalist Hiring Coders #2 | Finalist HSM Coders 2021 | Full Stack Digital House | VTEX IO |
5 个月Catch up on my previous post on Event-driven architecture, here: https://www.dhirubhai.net/pulse/how-to-use-event-driven-architecture-digibee-platform-martin-embon-abahf/?trackingId=y1%2BzrJxWRMepUeGFvIgIFw%3D%3D