Introduction
.NET Architecture Weekly is a journal about learning software architecture on .NET and not just limited* to .NET only.
PS: Why? Because software architecture designs normally can use in any languages or frameworks :).
Week #5
1) Microservices Architecture Design Patterns – Part 3
XI) Retry Pattern
Retry pattern is a common pattern for recovering from transient errors such as errors that occur for a short period of time. The retry can be implemented in different ways such as Fixed delay, Incremental delay, Exponential Backoff and etc.
--- title: Retry Pattern --- flowchart LR task(Task Service) --x|Request 1| notif(Notification Service) task --x |Fixed Delay - Request 2| notif task --x |Increment Delay - Request 3| notif task --x |Exponential Backoff - Request 4| notif notif --> |Response or give up| task style task fill:#0f0 style notif fill:#ff0 linkStyle 0,1,2,3 stroke:#f00, 2px; linkStyle 4 stroke:#0f0, 2px;
XII) Sidecar Pattern
Sidecar pattern is used to promote separation of concerns by offloading processing of some kind to a separate / side module that gets along with a primary app. Common sidecar modules are logging service, configuration service, monitor service and etc.
--- title: Sidecar Pattern --- flowchart TD main[Primary App] <--> log(Logging Service) main <--> config(Configuration Service) main <--> monitor(Monitoring Service) subgraph Sidecar log <--> config config <--> monitor monitor <--> log end style main fill:#0f0 style log fill:#ff0 style config fill:#f66 style monitor fill:#0ff
XIII) Strangler / Vine Pattern
Strangler / Vine pattern is a pattern that gradually migrates parts of a monolith to fully microservices architecture.
%%{init: { 'logLevel': 'debug', 'theme': 'default' , 'themeVariables': { 'cScale0': '#ff0000', 'cScaleLabel0': '#ffffff', 'cScale1': '#00ff00', 'cScale2': '#0000ff', 'cScaleLabel2': '#ffffff' } } }%% timeline title Strangling the Todo monolith app section Monolith Jan : Monolith (API Gateway, User, Task, Notification) section Monolith + Microservices Feb : Monolith (User, Task, Notification) : Service API Gateway Mar : Monolith (Task, Notification) : Service API Gateway : Service User Apr : Monolith (Notification): Service API Gateway : Service User : Service Task section Microservices May : Service API Gateway : Service User : Service Task : Service Notification
XIV) Aggregator Pattern
The Aggregator pattern is a composition pattern in microservices architecture. It looks quite similar with API Gateway pattern initially from diagram, but if you go in detail, the key difference is it will composite response from other services.
--- title: Aggregator Pattern --- graph LR GW[API Gateway] --> Agg[Post Aggregate] subgraph Aggregator Agg -->|REST call| A[Post Service]What Agg -->|REST call| B[Comment Service] Agg -->|REST call| C[Share Service] A -->|DB call| D[DB A] B -->|DB call| E[DB B] C -->|DB call| F[DB C] end style Agg fill:#f9d0c4 style GW fill:#f0b37e style A fill:#a9dc76 style B fill:#a9dc76 style C fill:#a9dc76 style D fill:#78dce8 style E fill:#78dce8 style F fill:#78dce8
XV) Chain of Responsibility Pattern
Chain of Responsibility Pattern combines multiple chained outputs and returns it as a single output. A client sends a request to Service A, and from A to Service B and to Service C, then from C, it returns to B and back to A, lastly, it’s from A, it returns response to the client. Therefore, the chains should not be too many, else it will be slowing down the response.
--- title: Chain of Responsibility Pattern --- graph RL UI[Browser] <--> GW[API Gateway] GW --> |1. REST call| A[Service A] subgraph Chained A -->|2. REST call| B[Service B] B -->|3. REST call| C[Service C] C -->|4. Response C| B B -->|5. Response B+C| A end A -->|6. Response A+B+C| GW style UI fill:#f9d0c4 style GW fill:#f0b37e style A fill:#a9dc76 style B fill:#a9dc76 style C fill:#a9dc76 linkStyle default stroke:#000, 1px; linkStyle 1,2,3 stroke:#00f, 2px; linkStyle 4,5,6 stroke:#0f0, 2px;
Reference:
https://blog.bitsrc.io/retry-pattern-3f7221913e41
https://dzone.com/articles/sidecar-design-pattern-in-your-microservices-ecosy-1
https://learn.microsoft.com/en-us/azure/architecture/patterns/sidecar
Pingback: .NET Architecture Weekly #6 | Malaysia C# Developer and Writing✍ Blog