Implement Enterprise Design Patterns in Distributed Systems
A reference skill covering twelve distributed-systems patterns - CQRS, Saga, Circuit Breaker, Outbox, and more.
Why it matters
Architect and implement proven distributed system patterns (CQRS, Event Sourcing, Saga, Circuit Breaker, and 8 more) to build resilient, scalable microservices that handle failures gracefully and maintain consistency across service boundaries.
Outcomes
What it gets done
Separate read and write models with CQRS to independently scale query and command paths
Implement saga orchestration with compensating transactions for multi-service workflows
Add circuit breakers and bulkheads to prevent cascade failures across microservices
Solve dual-write problems with outbox pattern for atomic DB and message queue updates
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-patterns | bash Overview
MONOPOLY - Design Patterns Deep Dive
A reference skill covering twelve distributed-systems patterns, each with what it is, when to use it, an implementation sketch, and trade-offs. Use when designing or reviewing a distributed system and need to pick the right pattern for a specific problem.
What it does
MONOPOLY - Design Patterns Deep Dive is a reference skill covering twelve distributed-systems patterns: CQRS, Event Sourcing, the Saga pattern, Circuit Breaker, Bulkhead, Strangler Fig, Outbox pattern, Consistent Hashing, Backpressure, Leader Election, Two-Phase Commit, and cache strategies (read-through, write-through, write-behind, cache-aside) - each with what it is, when to use it, an implementation sketch, and trade-offs.
When to use - and when NOT to
Use this as a reference when designing or reviewing a distributed system and need to pick the right pattern for a specific problem: separating read and write load (CQRS), needing a full audit trail (Event Sourcing), coordinating a multi-service transaction (Saga, or Two-Phase Commit only when strong cross-service consistency is an absolute requirement), preventing cascade failures (Circuit Breaker, Bulkhead), migrating a monolith incrementally (Strangler Fig), solving the dual-write problem (Outbox), distributing keys across nodes (Consistent Hashing), slowing producers to match consumers (Backpressure), electing a single coordinator (Leader Election), or choosing a caching strategy. It is explicitly a reference document, not exhaustive, and every architecture choice still needs verification before production.
Inputs and outputs
Concrete guidance per pattern: CQRS splits write and read paths - for example a PostgreSQL write DB and a Redis or Elasticsearch read DB, synced via CDC tools like Debezium - trading eventual consistency for independent scaling. Event Sourcing stores an append-only event log (Kafka, EventStoreDB) with periodic snapshots and consumer-built projections. Saga runs as choreography (services react to events autonomously) or orchestration (a central coordinator), with compensating transactions undoing prior steps on failure. Circuit Breaker moves through CLOSED, OPEN, and HALF-OPEN states with example thresholds (open at 50% failure over 10 requests, stay open 30 seconds) via tools like Resilience4j, Polly, or Envoy. Bulkhead isolates resources via thread-pool, semaphore, or process-level separation so one slow service can't starve another. Strangler Fig migrates a monolith in five phases, proxying traffic to new services feature by feature until the monolith is empty. Outbox writes an event row in the same DB transaction as the state change, then relays it to a queue, guaranteeing at-least-once delivery. Consistent Hashing remaps only K/N keys when nodes change, using virtual nodes for even distribution. Backpressure strategies include drop, buffer, block, and rate-limit. Leader Election uses Raft (etcd, CockroachDB, Consul), ZooKeeper/ZAB (Kafka, HBase), or the simpler, non-fault-tolerant Bully algorithm. Two-Phase Commit's prepare and commit phases guarantee atomicity but create a single point of failure and low throughput under contention, so Saga is preferred in most microservice architectures. Cache strategies range from read-through and write-through (strong consistency, higher latency) to write-behind (low latency, data-loss risk) and cache-aside (most common, application-owned).
Integrations
References named real-world implementations throughout: Amazon's order service and LinkedIn's feed for CQRS, Debezium for CDC-based outbox relay and event sourcing, Hystrix, Resilience4j, Polly, and Envoy for circuit breaking, and etcd, ZooKeeper, Consul, and Redis Redlock for leader election and distributed locking.
Who it's for
Backend and platform engineers designing or reviewing distributed system architecture who need a fast, trade-off-aware reference for a specific pattern instead of researching each one from scratch.
FAQ
Common questions
Discussion
Questions & comments ยท 0
Sign In Sign in to leave a comment.