Skip to content

Patterns from Distributed Systems

High-throughput messaging and trading systems push throughput patterns to the extreme.

PatternProjectWhereWhat It Does
Ring BufferLMAX DisruptorRingBuffer.javaCore data structure — 6M orders/sec at LMAX Exchange
Batch ProcessingApache KafkaRecordAccumulator.javaAccumulate records into batches per partition for throughput
Circuit BreakerNetflix HystrixHystrixCircuitBreaker.javaThree-state circuit breaker for microservice resilience
Circuit BreakerSony gobreakergobreaker.goGo circuit breaker with generation-based staleness detection
BackpressureReactive StreamsSubscription.javarequest(n) pull-based flow control specification
Write-Ahead Logetcdwal.goRaft consensus WAL — source of truth for distributed state
Write-Ahead LogPostgreSQLxlog.cTransaction WAL for crash recovery, replication, PITR
MVCCPostgreSQLheapam_visibility.cHeapTupleSatisfiesMVCC — snapshot isolation visibility check
MVCCetcdkvstore.goMulti-version key-value store powering Kubernetes config
Consistent Hashinggroupcacheconsistenthash.goHash ring with virtual replicas for distributed caching
Actor ModelAkkaActor.scalatrait Actor — message-driven concurrency for JVM
Actor ModelErlang/OTPerl_process.hBEAM VM process struct — lightweight actor with mailbox
Rate LimiterNginxngx_http_limit_req_module.cLeaky bucket rate limiting for HTTP requests
Logical Clocketcdmvcc/revision.goMonotonic revision counter for event ordering across cluster
Logical ClockLevelDBdb_impl.cc sequence numberSequence numbers order all writes without wall-clock time
Retry BackoffKubernetesbackoff.goPod restart backoff, API server retries with exponential delay
TombstoneCassandraTombstone markersDelete markers in distributed delete propagation
LSM TreeLevelDBdb_impl.ccBuffer writes in memory, flush to sorted files, compact in background
CheckpointingPostgreSQLcheckpointer.cPeriodic state snapshot bounds WAL replay time on crash recovery

How They Compose: A Distributed Write

When a client writes a key to a distributed database like etcd, patterns chain across the entire path:

Client: PUT /key "value"
1
Rate Limiter

The gateway applies a token bucket to prevent any single client from overwhelming the cluster.

2
Consistent Hashing

The router determines which node owns this key. Virtual nodes ensure load stays balanced even when nodes join/leave.

3
Write-Ahead Log

Before modifying state, the leader appends the operation to a WAL on disk. If the process crashes, replay recovers state.

4
Logical Clock

The write gets a monotonic revision number. No wall-clock sync needed — all nodes agree on ordering via the revision.

5
MVCC

The new version is stored alongside old versions. Concurrent readers see a consistent snapshot without blocking the write.

6
Checkpointing

Periodically, the system takes a snapshot. Future crash recovery replays only the WAL entries after the last checkpoint.

The patterns form a durability pipeline: rate limiting protects the system, consistent hashing routes the request, WAL ensures durability, logical clocks order events, MVCC provides isolation, and checkpoints bound recovery time.

Further Reading

Released under the MIT License.