🌍 Distributed & Cloud Patterns

A. Patterns of distributed systems (Unmesh Joshi) ⭐

PatternProblem → solutionWhere you’ve seen itOrbit
Write-ahead logDurability → log before applyingPostgres WAL, KafkaRun event history
Segmented logHuge logs → split into segmentsKafka segmentsHistory partitioning
Low/high-water markWhat’s safe to read or deleteKafka HW, Postgres checkpointsConsumer progress
Leader & followersSingle writerKafka, Postgres—
HeartbeatDetect failureK8s node leasesWorker heartbeats
Lease ⭐Time-bound ownershipetcd, K8s leader electionTask leases
Fencing token / generation clock ⭐Reject stale ownersRaft terms, Kafka leader epochsLease epoch checked on step completion
QuorumMajority agreementRaft, Dynamo—
Idempotent receiver ⭐Dedupe retriesKafka idempotent producerTool calls with idempotency keys
Request pipeline / batchingThroughputKafka producer, Redis pipeliningEmbedding batches
Consistent hashingRebalance with minimal movementDynamo, Cassandra, Envoy ring hashSticky routing of runs to engine shards
Gossip disseminationCluster membershipCassandra, Redis Cluster—
Version vector / Lamport clockOrdering without synchronized clocksDynamoEvent ordering discussion

B. Reliability & resilience

Timeout ⭐ · Retry with exponential backoff + jitter ⭐ · Circuit breaker · Bulkhead · Rate limiting / throttling · Load shedding · Fallback / graceful degradation · Health endpoint monitoring · Retry budget · Idempotency key · Hedged requests (tail latency) · Deadline propagation

C. Messaging & data

PatternUseOrbit
Transactional outbox ⭐Atomically update the DB + publish an event (no dual writes)api + engine
InboxConsumer-side dedupehooks, notification
Competing consumersScale a queue horizontallyworkers
Queue-based load levelingAbsorb spikestask queue + KEDA
Priority queuePremium tenants firsttenant tiers
Sequential convoyOrder per key, parallel across keysKafka key = runId
Claim check ⭐Keep large payloads out of messages (store in S3, pass a reference)Documents, big LLM outputs
Pub/SubFan-outrun events
Dead letter queuePark poison messageswebhooks
CQRS + materialized viewSeparate read modelsrun search in OpenSearch
Event sourcingState = eventsrun history
Saga / compensating transaction ⭐Cross-service consistencyUC3 refunds
Scheduler-agent-supervisor ⭐Coordinate and recover distributed stepsThis is literally the Orbit engine
Pipes & filtersComposable processing stagesIngestion pipeline
ShardingScale writesEvent history by run_id hash

D. Edge, deployment & topology (cloud design patterns)

API gateway (routing, aggregation, offloading auth/TLS/rate limits) · BFF · Sidecar · Ambassador · Anti-corruption layer · Strangler fig · Valet key (presigned URLs) ⭐ · Static content hosting/CDN · Deployment stamps / cell-based architecture ⭐ · Geode (multi-region) · Leader election · Operator (controller) pattern ⭐ · Blue/green · Canary · Feature flags · Expand/contract migrations

🔬 Katas

  • Implement a lease + fencing token with Postgres, then show a stale worker’s write being rejected (simulate a GC pause with SIGSTOP)
  • Retry storm simulation: 3 service layers × 3 retries = 27× amplification → fix with budgets + jitter
  • Consistent hash ring with virtual nodes: measure key movement when adding a node (≈ 1/N)
  • Hedged requests to an LLM provider: p99 improvement vs cost increase
  • Claim-check refactor: move >256 KB step outputs to MinIO; measure Kafka throughput before/after