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.
Sobre el 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.
Más como éste
Meet the latest Red Hat OpenShift Superheroes
Bridging the gap: Red Hat Academy shaping open source talent in APAC
The Agile_Revolution | Command Line Heroes
Are We As Productive As We Think We Are? | Compiler
Navegar por canal
Automatización
Las últimas novedades en la automatización de la TI para los equipos, la tecnología y los entornos
Inteligencia artificial
Descubra las actualizaciones en las plataformas que permiten a los clientes ejecutar cargas de trabajo de inteligecia artificial en cualquier lugar
Nube híbrida abierta
Vea como construimos un futuro flexible con la nube híbrida
Seguridad
Vea las últimas novedades sobre cómo reducimos los riesgos en entornos y tecnologías
Edge computing
Conozca las actualizaciones en las plataformas que simplifican las operaciones en el edge
Infraestructura
Vea las últimas novedades sobre la plataforma Linux empresarial líder en el mundo
Aplicaciones
Conozca nuestras soluciones para abordar los desafíos más complejos de las aplicaciones
Virtualización
El futuro de la virtualización empresarial para tus cargas de trabajo locales o en la nube