Install any skill in seconds. Free to start, no credit card required.
Get Started Free →When designing distributed systems for scalability, reliability, and consistency. Covers CAP/PACELC theorems, consistency models (strong, eventual, causal), replication patterns (leader-follower, multi-leader, leaderless), partitioning strategies (hash, range, geographic), transaction patterns (saga, event sourcing, CQRS), resilience patterns (circuit breaker, bulkhead), service discovery, and caching strategies for building fault-tolerant distributed architectures.
.claude/skills/ancoleman-designing-distributed-systems/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-15 | ✗→✓ | ▲ Improved | 296% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 151% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 292% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 168% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 179% | 0% |
Design scalable, reliable, and fault-tolerant distributed systems using proven patterns and consistency models.
Distributed systems are the foundation of modern cloud-native applications. Understanding fundamental trade-offs (CAP theorem, PACELC), consistency models, replication patterns, and resilience strategies is essential for building systems that scale globally while maintaining correctness and availability.
Apply when:
CAP Theorem: In a distributed system experiencing a network partition, choose between Consistency (C) or Availability (A). Partition tolerance (P) is mandatory.
Network partitions WILL occur → Always design for P
During partition:
├─ CP (Consistency + Partition Tolerance)
│ Use when: Financial transactions, inventory, seat booking
│ Trade-off: System unavailable during partition
│ Examples: HBase, MongoDB (default), etcd
│
└─ AP (Availability + Partition Tolerance)
Use when: Social media, caching, analytics, shopping carts
Trade-off: Stale reads possible, conflicts need resolution
Examples: Cassandra, DynamoDB, RiakPACELC: Extends CAP to consider normal operations (no partition).
Strong Consistency ◄─────────────────────► Eventual Consistency
│ │ │
Linearizable Causal Consistency Convergent
(Slowest, (Middle Ground, (Fastest,
Most Consistent) Causally Ordered) Eventually Consistent)Strong Consistency (Linearizability):
Eventual Consistency:
Causal Consistency:
Bounded Staleness:
1. Leader-Follower (Single-Leader):
2. Multi-Leader:
3. Leaderless (Dynamo-style):
Hash Partitioning (Consistent Hashing):
Range Partitioning:
Geographic Partitioning:
Circuit Breaker:
[Closed] → Normal operation
│ (failures exceed threshold)
▼
[Open] → Fail fast (don't call failing service)
│ (timeout expires)
▼
[Half-Open] → Try single request
│ success → [Closed]
│ failure → [Open]Bulkhead Isolation:
Timeout and Retry:
Rate Limiting and Backpressure:
Saga Pattern:
Choreography: Services react to events
Order Service → OrderCreated event
Payment Service → listens → PaymentProcessed event
Inventory Service → listens → InventoryReserved event
(Compensating: if payment fails → InventoryReleased event)Orchestration: Central coordinator
Saga Orchestrator:
1. Call Order Service
2. Call Payment Service
3. Call Inventory Service
(If step fails → call compensating transactions in reverse)Event Sourcing:
CQRS (Command Query Responsibility Segregation):
Client-Side Discovery:
Server-Side Discovery:
Service Mesh:
Cache-Aside (Lazy Loading):
Read:
1. Check cache → hit? return
2. Miss? Query database
3. Store in cache, returnWrite-Through:
Write:
1. Write to cache
2. Cache writes to database synchronously
3. Return successWrite-Behind (Write-Back):
Write:
1. Write to cache
2. Return success
3. Cache writes to database asynchronously (batched)Cache Invalidation:
Decision Tree:
├─ Money involved? → Strong Consistency
├─ Double-booking unacceptable? → Strong Consistency
├─ Causality important (chat, edits)? → Causal Consistency
├─ Read-heavy, stale tolerable? → Eventual Consistency
└─ Default? → Eventual (then strengthen if needed)├─ Single region writes? → Leader-Follower
├─ Multi-region writes + conflicts OK? → Multi-Leader
├─ Multi-region writes + no conflicts? → Leader-Follower with failover
└─ Maximum availability? → Leaderless (quorum)├─ Need range scans? → Range Partitioning (risk: hot spots)
├─ Data residency requirements? → Geographic Partitioning
└─ Default? → Hash Partitioning (consistent hashing)| System | If Partition | Else (Normal) | Use Case | |------------|--------------|---------------|--------------------| | Spanner | PC | EC (strong) | Global SQL | | DynamoDB | PA | EL (eventual) | High availability | | Cassandra | PA | EL (tunable) | Wide-column store | | MongoDB | PC | EC (default) | Document store | | Cosmos DB | PA/PC | EL/EC (5 levels) | Multi-model |
| Use Case | Consistency Model | |----------------------------|------------------------| | Bank account balance | Strong (Linearizable) | | Seat booking (airline) | Strong (Linearizable) | | Inventory stock count | Strong or Bounded | | Shopping cart | Eventual | | Product catalog | Eventual | | Collaborative editing | Causal | | Chat messages | Causal | | Social media likes | Eventual | | DNS records | Eventual |
| Configuration | W | R | N | Consistency | Use Case | |--------------|---|---|---|-------------|-------------| | Strong | 3 | 3 | 5 | Strong | Banking | | Balanced | 3 | 2 | 5 | Strong | Default | | Write-heavy | 2 | 3 | 5 | Strong | Logs | | Read-heavy | 3 | 1 | 5 | Eventual | Cache | | Max Avail | 1 | 1 | 5 | Eventual | Analytics |
For comprehensive coverage of specific topics, see:
Complete, runnable examples demonstrating patterns:
Visual representations for complex concepts:
Related Skills:
For Kubernetes deployment: See kubernetes-operations skill for pod anti-affinity, service mesh For infrastructure: See infrastructure-as-code skill for deploying distributed systems For databases: See databases-sql and databases-nosql for replication configuration For messaging: See message-queues skill for event-driven architectures, saga orchestration For monitoring: See observability skill for distributed tracing, monitoring patterns For testing: See performance-engineering skill for load testing distributed systems For security: See security-hardening skill for mTLS, service authentication
1. Choose replication: Multi-leader or Leaderless
2. Partition data geographically
3. Implement conflict resolution (LWW, vector clocks, app-specific)
4. Monitor replication lag
5. Add circuit breakers between datacenters1. Define saga steps and compensating actions
2. Choose choreography (events) or orchestration (coordinator)
3. Implement idempotent handlers (retries safe)
4. Publish events with outbox pattern (transactional)
5. Monitor saga progress and timeouts1. Use leaderless replication (N=5, W=3, R=2)
2. Partition with consistent hashing
3. Add circuit breakers for failing nodes
4. Implement read repair and anti-entropy
5. Monitor quorum healthDesign for Failure:
Choose Consistency Carefully:
Idempotency is Critical:
Monitor and Observe:
Partition Strategically:
Version Everything:
Distributed Monolith:
Two-Phase Commit (2PC) Overuse:
Ignoring Network Failures:
Strong Consistency Everywhere:
No Conflict Resolution Strategy:
Cache Stampede:
Replication Lag Too High:
Split-Brain Scenario:
Hot Partitions:
Saga Timeout/Stalled:
Conflict Resolution Failures:
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 15,610 | 15,271 | -2% | 1 | 1 | 0% | 2,479 | 6,219 | +151% | 0 | 0 | — |
case-02 | pass→pass | 7,333 | 6,540 | -11% | 1 | 1 | 0% | 1,271 | 4,986 | +292% | 0 | 0 | — |
case-03 | pass→pass | 13,151 | 9,368 | -29% | 1 | 1 | 0% | 1,965 | 5,263 | +168% | 0 | 0 | — |
case-04 | pass→pass | 10,705 | 9,556 | -11% | 1 | 1 | 0% | 1,904 | 5,303 | +179% | 0 | 0 | — |
case-05 | pass→pass | 10,569 | 9,739 | -8% | 1 | 1 | 0% | 1,577 | 5,239 | +232% | 0 | 0 | — |
case-06 | pass→pass | 9,923 | 9,194 | -7% | 1 | 1 | 0% | 1,474 | 5,244 | +256% | 0 | 0 | — |
case-07 | pass→pass | 9,126 | 7,061 | -23% | 1 | 1 | 0% | 1,558 | 4,925 | +216% | 0 | 0 | — |
case-08 | fail→fail | 16,800 | 12,328 | -27% | 1 | 1 | 0% | 2,723 | 5,754 | +111% | 0 | 0 | — |
case-09 | pass→pass | 5,374 | 7,225 | +34% | 1 | 1 | 0% | 852 | 4,837 | +468% | 0 | 0 | — |
case-10 | pass→pass | 4,186 | 6,331 | +51% | 1 | 1 | 0% | 672 | 4,794 | +613% | 0 | 0 | — |
case-11 | pass→pass | 5,549 | 4,510 | -19% | 1 | 1 | 0% | 927 | 4,511 | +387% | 0 | 0 | — |
case-12 | pass→pass | 11,397 | 12,717 | +12% | 1 | 1 | 0% | 1,873 | 5,772 | +208% | 0 | 0 | — |
case-13 | pass→pass | 5,064 | 4,234 | -16% | 1 | 1 | 0% | 742 | 4,486 | +505% | 0 | 0 | — |
case-14 | pass→pass | 7,739 | 9,627 | +24% | 1 | 1 | 0% | 1,182 | 5,320 | +350% | 0 | 0 | — |
case-15 | fail→pass | 9,030 | 12,852 | +42% | 1 | 1 | 0% | 1,444 | 5,725 | +296% | 0 | 0 | — |
case-16 | pass→pass | 4,837 | 11,681 | +141% | 1 | 1 | 0% | 760 | 5,253 | +591% | 0 | 0 | — |
case-17 | pass→pass | 5,330 | 7,446 | +40% | 1 | 1 | 0% | 794 | 5,119 | +545% | 0 | 0 | — |
case-18 | pass→pass | 9,789 | 13,589 | +39% | 1 | 1 | 0% | 1,505 | 5,794 | +285% | 0 | 0 | — |
case-19 | fail→fail | 13,196 | 11,386 | -14% | 1 | 1 | 0% | 2,174 | 5,663 | +160% | 0 | 0 | — |
case-20 | pass→pass | 8,572 | 6,110 | -29% | 1 | 1 | 0% | 1,481 | 4,875 | +229% | 0 | 0 | — |
case-21 | pass→pass | 2,813 | 3,274 | +16% | 1 | 1 | 0% | 466 | 4,371 | +838% | 0 | 0 | — |
case-22 | pass→pass | 18,166 | 13,194 | -27% | 1 | 1 | 0% | 3,257 | 5,926 | +82% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +5 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.