Having a grasp of common architectural patterns is essential to designing software architecture at scale. Using them saves not only time but also ensures a reliable implementation of your design. There’s no need to reinvent the wheel when there’s an architectural pattern available that applies to an architecture you’re developing.
The following is a brief overview of the Saga architectural pattern.
Understanding the Saga pattern
The Saga pattern is one in which the steps of a transaction are chronicled according to a set of predefined actions. This chronicle is called a saga. As each step in a transaction is executed, a controller service compares the result of the step against the saga definition. If a step is executed successfully, the next step in the saga is executed. Should a step fail, all the steps defined in the saga are set back to the last known good state.
The Saga pattern is well-suited to transactions that execute over various independent, loosely coupled services in which each service is hosted at a separate location.
Pros
- Makes transaction management in a loosely coupled, message-driven environment possible.
- Well-suited to transactions that have a small number of steps (4 -5).
Cons
- Can be complex to manage, particularly if a transaction has a large number of steps and the environment is asynchronous.
- Requires a good deal of programming, particularly to support rollback in an asynchronous, message-driven environment.
Putting it all together
Handling a transaction that occurs over a large number of loosely coupled or independent services is a difficult undertaking. It’s even more difficult when the transaction occurs in systems that use asynchronous communication. The Saga pattern addresses the issues head-on.
Basically, the pattern describes how a transaction is supposed to go. A controller will execute these steps among a variety of services. Should a step fail, the controller will restore all the services affected by the transaction back to the last known good state.
The Saga pattern can be difficult to implement, particularly in an asynchronous environment. But the safety it provides makes it worth the efforts required to implement the pattern.
Über den Autor
Bob Reselman is a nationally known software developer, system architect, industry analyst, and technical writer/journalist. Over a career that spans 30 years, Bob has worked for companies such as Gateway, Cap Gemini, The Los Angeles Weekly, Edmunds.com and the Academy of Recording Arts and Sciences, to name a few. He has held roles with significant responsibility, including but not limited to, Platform Architect (Consumer) at Gateway, Principal Consultant with Cap Gemini and CTO at the international trade finance company, ItFex.
Ähnliche Einträge
Meet the latest Red Hat OpenShift Superheroes
Bridging the gap: Red Hat Academy shaping open source talent in APAC
What Do Kids Learn When They Learn About Tech? | Compiler
The COBOL Chronicles | Compiler: Legacies
Nach Thema durchsuchen
Automatisierung
Das Neueste zum Thema IT-Automatisierung für Technologien, Teams und Umgebungen
Künstliche Intelligenz
Erfahren Sie das Neueste von den Plattformen, die es Kunden ermöglichen, KI-Workloads beliebig auszuführen
Open Hybrid Cloud
Erfahren Sie, wie wir eine flexiblere Zukunft mit Hybrid Clouds schaffen.
Sicherheit
Erfahren Sie, wie wir Risiken in verschiedenen Umgebungen und Technologien reduzieren
Edge Computing
Erfahren Sie das Neueste von den Plattformen, die die Operations am Edge vereinfachen
Infrastruktur
Erfahren Sie das Neueste von der weltweit führenden Linux-Plattform für Unternehmen
Anwendungen
Entdecken Sie unsere Lösungen für komplexe Herausforderungen bei Anwendungen
Virtualisierung
Erfahren Sie das Neueste über die Virtualisierung von Workloads in Cloud- oder On-Premise-Umgebungen