Skip to content

Instantly share code, notes, and snippets.

@gc-garcol
Created July 10, 2024 01:54
Show Gist options
  • Save gc-garcol/4d5cabc55c0a66731fe976570ddc781c to your computer and use it in GitHub Desktop.
Save gc-garcol/4d5cabc55c0a66731fe976570ddc781c to your computer and use it in GitHub Desktop.
distributed design pattern

Most-Used Distributed System Design Patterns

Ambassador — Proxy

image

image

Circuit Breaker

image

Closed: In this state, the circuit breaker allows normal service communication, and requests go through to the service. Circuit breaker monitors the responses from the service for errors ( 4XX , 5XX HTTP Code ). If the responses are successful ( 200 OK ) with no issues, it remains in the closed state.

Open: When the number of failures reaches a threshold, the circuit breaker switches to the open state (4XX , 5XX HTTP Code with some threshold count < 30 ), preventing requests from reaching the service and providing a fallback response. (Threshold Value like 30 failures within 10 seconds)

Half-Open: Once the timeout or reset interval passes, the circuit breaker goes to the “Half-Open” state. It allows a limited number of test requests to pass through to the service to see if the service has recovered or not. If the test requests succeed ( 200 OK ) , it means the service has recovered and the circuit breaker goes back to “Closed” state. If any of the test requests fails, it means the service has still issues and the circuit breaker goes to “Open” state to block further requests.

CQRS (Command Query Responsibility Segregation)

CQRS separates reads and writes into different databases, Commands performs update data, Queries performs read data.

image

image

Event Sourcing: journal of the live events

image

Sidecar Pattern

Deploys auxiliary components (sidecars) alongside the main service containers to manage cross-cutting concerns like logging, monitoring, and configuration.

image

Leader Selection

image

image

Publisher/Subscriber

image

image

Sharding

image

image

Bulkhead

Isolates components in a system so that a failure in one component does not cause a system-wide failure.

image

Cache-Aside

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment