\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Kiran P (kirandp)} \pdfinfo{ /Title (java-microservices-imp-patterns.pdf) /Creator (Cheatography) /Author (Kiran P (kirandp)) /Subject (Java-Microservices-IMP-Patterns Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A35A4B} \definecolor{LightBackground}{HTML}{F9F4F3} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Java-Microservices-IMP-Patterns Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Kiran P (kirandp)} via \textcolor{DarkBackground}{\uline{cheatography.com/210594/cs/45443/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Kiran P (kirandp) \\ \uline{cheatography.com/kirandp} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 13th January, 2025.\\ Updated 13th January, 2025.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Circuit Breaker Design Pattern}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Definition:}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{The Circuit Breaker Design Pattern is used in Java microservices to handle potential failures gracefully and improve the system's resilience. It acts as a safety switch to prevent cascading failures in distributed systems.} \tn % Row Count 6 (+ 5) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{Key Concepts:} \tn % Row Count 7 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Closed State:}} Requests are allowed through. If failures reach a threshold, the circuit trips to Open.\{\{nl\}\} {\bf{Open State:}} Requests are blocked, and failures are immediately returned. This prevents overloading the failing service.\{\{nl\}\} {\bf{Half-Open State:}} After a timeout, a few requests are allowed to test if the service has recovered. If successful, the circuit closes again; otherwise, it reopens.\{\{nl\}\}} \tn % Row Count 16 (+ 9) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{Benefits:} \tn % Row Count 17 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Fault Isolation:}} Prevents a single service failure from affecting others.\{\{nl\}\} {\bf{Improved Resilience:}} Allows systems to degrade gracefully instead of failing entirely.\{\{nl\}\} {\bf{Faster Recovery:}} Reduces load on failing services, helping them recover faster.} \tn % Row Count 23 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{Frameworks like Resilience4j or Hystrix are commonly used to implement the Circuit Breaker pattern.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Single Database Per Service}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Definition:}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{The Single Database per Service design pattern is a key principle in microservices architecture that ensures each microservice has its own dedicated database. This pattern supports the autonomy, scalability, and resilience of microservices.} \tn % Row Count 6 (+ 5) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Features}}} \tn % Row Count 7 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Service Ownership:}} Each microservice is responsible for managing its own database schema, data, and access logic.} \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Decoupling:}} Services are not tightly coupled through shared databases, ensuring changes in one service do not directly affect others.} \tn % Row Count 13 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Data Isolation:}} Prevents direct access to a service's data by other services. Communication happens through APIs or events.} \tn % Row Count 16 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Benefits:}}} \tn % Row Count 17 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Encapsulation:}} Data access logic remains confined within the service, promoting loose coupling.\{\{nl\}\} {\bf{Independent Scaling:}} Each database can be optimized and scaled based on the specific service's needs.\{\{nl\}\} {\bf{Technology Flexibility:}} Different microservices can use different types of databases (e.g., SQL, NoSQL) based on their requirements.\{\{nl\}\} {\bf{Fault Isolation:}} Database issues in one service don't propagate to others.\{\{nl\}\}} \tn % Row Count 26 (+ 9) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Challenges:}}} \tn % Row Count 27 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Data Consistency:}} Maintaining consistency across multiple services becomes complex, especially during distributed transactions.\{\{nl\}\} {\bf{Data Duplication:}} Related data may need to be replicated across databases, increasing storage requirements.\{\{nl\}\} {\bf{Communication Overhead:}} Cross-service data access requires inter-service communication (e.g., via APIs), which can add latency.\{\{nl\}\}} \tn % Row Count 35 (+ 8) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{API Gateway Design Pattern}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Features}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Routing:}} Routes incoming client requests to the appropriate microservices.\{\{nl\}\} {\bf{Aggregation:}}Combines responses from multiple services to provide a single, consolidated response.\{\{nl\}\} {\bf{Cross-Cutting Concerns:}} Handles common tasks like authentication, authorization, rate limiting, caching, logging, and monitoring.\{\{nl\}\} {\bf{Protocol Translation:}} Converts protocols (e.g., HTTP to gRPC) if needed\{\{nl\}\}} \tn % Row Count 10 (+ 9) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Advantages}}} \tn % Row Count 11 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{Simplifies client interactions by abstracting service details.\{\{nl\}\} Reduces client-to-service communication complexity.\{\{nl\}\} Centralizes concerns like security and logging, ensuring consistency.\{\{nl\}\}} \tn % Row Count 16 (+ 5) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Challenges}}} \tn % Row Count 17 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{Can become a single point of failure if not designed with redundancy.\{\{nl\}\} May introduce latency due to added processing.\{\{nl\}\} Requires proper scaling to handle high traffic.\{\{nl\}\}} \tn % Row Count 21 (+ 4) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Tools Used for Implementation:}}} \tn % Row Count 22 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Netflix Zuul:}} A flexible API Gateway.\{\{nl\}\} {\bf{Kong:}} An open-source API Gateway with plugin support.\{\{nl\}\} {\bf{Spring Cloud Gateway:}} A Java-based API Gateway for Spring applications.\{\{nl\}\} {\bf{AWS API Gateway:}} A managed solution by AWS.\{\{nl\}\}} \tn % Row Count 27 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{BulkHead Design Pattern}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Key Concept}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{The system is divided into independent partitions (bulkheads), like compartments in a ship, to contain failures within one partition.\{\{nl\}\} Each bulkhead has dedicated resources (e.g., thread pools, memory, connections) to prevent resource exhaustion from affecting other parts of the system.\{\{nl\}\}} \tn % Row Count 7 (+ 6) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Pros:}}} \tn % Row Count 8 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Fault Isolation:}} Limits the impact of failures to specific services or components.\{\{nl\}\} {\bf{Improved Resilience:}} Ensures critical parts of the system remain operational even when some fail.\{\{nl\}\} {\bf{Resource Protection:}} Prevents one service from consuming all available resources.\{\{nl\}\}} \tn % Row Count 14 (+ 6) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Challenges}}} \tn % Row Count 15 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{Overhead due to managing multiple resource pools.\{\{nl\}\} Requires careful tuning of resource limits for optimal performance} \tn % Row Count 18 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Implementation Tools}}} \tn % Row Count 19 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{Use {\bf{thread pools, connection pools, or process isolation}} to allocate resources to specific services.\{\{nl\}\} Frameworks like {\bf{Resilience4j}} support bulkhead isolation.\{\{nl\}\}} \tn % Row Count 23 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Strangler Fig Design Pattern}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Key Concept:}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{Inspired by the way a strangler fig tree grows around a host tree, eventually replacing it.\{\{nl\}\} New features are built as independent microservices, while the monolithic application continues to handle legacy functionality.\{\{nl\}\} Over time, the monolith is "strangled" as its functionality is replaced by microservices.\{\{nl\}\}} \tn % Row Count 8 (+ 7) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Process}}} \tn % Row Count 9 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Identify Modules:}} Analyze the monolith and identify modules or functionalities to migrate.\{\{nl\}\} {\bf{Build New Services:}} Create microservices for new features or existing modules.\{\{nl\}\} {\bf{Redirect Traffic:}} Use an API Gateway or routing layer to direct requests to the appropriate service (new microservice or monolith).\{\{nl\}\} {\bf{Decommission Monolith:}} Gradually phase out the monolith as its responsibilities are fully transitioned to microservices.\{\{nl\}\}} \tn % Row Count 19 (+ 10) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Pros}}} \tn % Row Count 20 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Incremental Migration:}} Avoids the risks of a complete rewrite.\{\{nl\}\} {\bf{Reduced Downtime:}} Allows the system to remain operational during migration.\{\{nl\}\} {\bf{Modernization:}} Enables the adoption of new technologies and practices.\{\{nl\}\}} \tn % Row Count 25 (+ 5) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Challenges:}}} \tn % Row Count 26 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Complexity in Integration:}} Requires careful coordination between the monolith and microservices.\{\{nl\}\} {\bf{Extended Migration Time:}} The process can take a long time to complete.\{\{nl\}\}} \tn % Row Count 30 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{The Strangler Fig pattern allows for a smooth and low-risk transition to microservices while continuously delivering value.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Fallback Design Pattern}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Definition:}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{The {\bf{Fallback Design Pattern}} in microservices is a resilience pattern used to provide a backup response or alternative action when a service fails or is unavailable. It ensures that the system remains partially functional, offering a better user experience during failures.} \tn % Row Count 7 (+ 6) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Features:}}} \tn % Row Count 8 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Backup Response:}} Provides a default or cached response when the primary service fails.\{\{nl\}\} {\bf{Graceful Degradation:}} Allows the application to continue operating with limited functionality instead of crashing.\{\{nl\}\} {\bf{User Impact Mitigation:}} Minimizes disruptions for users by avoiding complete failures.\{\{nl\}\}} \tn % Row Count 15 (+ 7) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Pros:}}} \tn % Row Count 16 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{Improves system resilience and user experience.\{\{nl\}\} Reduces the impact of temporary service failures.\{\{nl\}\} Supports fault-tolerant design in distributed systems.\{\{nl\}\}} \tn % Row Count 20 (+ 4) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Challenges}}} \tn % Row Count 21 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{Designing meaningful fallback responses can be complex.\{\{nl\}\} Fallback logic must be carefully tested to avoid unexpected behavior.\{\{nl\}\}} \tn % Row Count 24 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{Frameworks like Resilience4j or Hystrix make implementing fallbacks.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Command Query Responsibility Segregation}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Definition}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{The {\bf{CQRS}} (Command Query Responsibility Segregation) design pattern in microservices separates the operations\{\{nl\}\} that modify data (commands) from the operations that read data (queries). \{\{nl\}\} This pattern optimizes performance, scalability, and flexibility in handling complex business requirements.} \tn % Row Count 8 (+ 7) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Key Concepts}}} \tn % Row Count 9 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Commands:}} Handle write operations (e.g., creating, updating, or deleting data).\{\{nl\}\} {\bf{Queries:}} Handle read operations to retrieve data.\{\{nl\}\} {\bf{Separate Models:}} Use distinct data models for write (transactional consistency) and read (optimized for queries).\{\{nl\}\}} \tn % Row Count 15 (+ 6) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Pros}}} \tn % Row Count 16 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Scalability:}} Scale read and write operations independently.\{\{nl\}\} {\bf{Performance:}} Optimize query responses with denormalized or precomputed data.\{\{nl\}\} {\bf{Flexibility:}} Tailor read and write models to different requirements.\{\{nl\}\}} \tn % Row Count 21 (+ 5) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Challenges}}} \tn % Row Count 22 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Increased complexity}} due to managing separate models and synchronization.\{\{nl\}\} {\bf{Potential for eventual consistency}} between write and read models.\{\{nl\}\}} \tn % Row Count 26 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{Use frameworks like Axon or Spring Boot to simplify CQRS implementation.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Saga Design Pattern}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Definition}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{The {\bf{Saga Design Pattern}} is a microservices design pattern for managing distributed transactions\{\{nl\}\} in a consistent and reliable way without using a centralized transaction coordinator. \{\{nl\}\} It breaks down a transaction into a sequence of smaller,\{\{nl\}\} independent steps (local transactions) across services, ensuring eventual consistency.\{\{nl\}\}} \tn % Row Count 9 (+ 8) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Concepts}}} \tn % Row Count 10 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Choreography:}} Each service independently performs its local transaction and publishes events for others to react to.\{\{nl\}\} {\bf{Orchestration:}} A central orchestrator coordinates the sequence of steps by invoking the necessary services.\{\{nl\}\} {\bf{Compensation:}} If a failure occurs, previously completed steps are undone using compensating actions.\{\{nl\}\}} \tn % Row Count 18 (+ 8) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Pros}}} \tn % Row Count 19 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{Enables distributed transactions without locking resources.\{\{nl\}\} Improves system resilience and scalability.\{\{nl\}\} Works well in asynchronous and event-driven architectures.\{\{nl\}\}} \tn % Row Count 23 (+ 4) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Implementation Tools}}} \tn % Row Count 24 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{Use tools like Kafka or RabbitMQ for event-driven sagas.\{\{nl\}\} Frameworks like Axon or Camunda help with orchestration.} \tn % Row Count 27 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{The Saga pattern ensures that distributed transactions are managed reliably while maintaining the independence of microservices.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Messenging Design Pattern}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Definition}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{The Messaging Design Pattern in microservices facilitates asynchronous communication between services using message brokers or event buses. It decouples services, enabling them to operate independently while improving scalability and resilience.} \tn % Row Count 6 (+ 5) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Important Concepts}}} \tn % Row Count 7 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Asynchronous Communication:}} Services exchange messages without waiting for immediate responses.\{\{nl\}\} {\bf{Message Broker:}} A central component (e.g., Kafka, RabbitMQ, AWS SQS) routes messages between producers (senders) and consumers (receivers).\{\{nl\}\} {\bf{Decoupling:}} Producers and consumers are independent, knowing only about the message format, not each other.\{\{nl\}\}} \tn % Row Count 15 (+ 8) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Pros}}} \tn % Row Count 16 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Scalability:}} Services can process messages at their own pace.\{\{nl\}\} {\bf{Fault Tolerance:}} Messages can be retried or queued if a service is unavailable.\{\{nl\}\} {\bf{Decoupling:}} Changes in one service don't require changes in others.\{\{nl\}\}} \tn % Row Count 21 (+ 5) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Challenges}}} \tn % Row Count 22 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{{\bf{Message Ordering:}} Ensuring the correct sequence of message processing can be complex.\{\{nl\}\} {\bf{Message Duplication:}} Requires handling duplicate messages for idempotency.\{\{nl\}\} {\bf{Operational Overhead:}} Managing message brokers adds complexity.\{\{nl\}\}} \tn % Row Count 28 (+ 6) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{{\bf{Implementation Tools}}} \tn % Row Count 29 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{Use messaging protocols like AMQP, MQTT, or Kafka Streams.\{\{nl\}\} Ensure messages are durable, idempotent, and well-structured (e.g., JSON, Avro).\{\{nl\}\}} \tn % Row Count 33 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{The Messaging pattern is fundamental in microservices for building resilient, scalable, and loosely coupled systems.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \end{document}