sys-d Visualizer
Interactive visualizations of distributed systems primitives — built from scratch in TypeScript.
Rate Limiting
Fixed Window Counter
Divide time into fixed windows with a counter per window. Simple but has the boundary burst problem.
Sliding Window Log
Store every request timestamp and filter old ones. 100% accurate but memory intensive.
Sliding Window Counter
Hybrid approach: uses weighted counters from current + previous windows. Best of both worlds.
Token Bucket
Tokens refill at a fixed rate. Each request consumes one. Allows controlled bursting up to bucket capacity.
Leaky Bucket
Requests fill a bucket that drains at a constant rate. Smooths bursty traffic into a steady flow.
Resilience
Circuit Breaker
Prevent cascading failures by switching between CLOSED, OPEN, and HALF_OPEN states based on failure thresholds.
Retry with Backoff
Automatically retry failed operations with exponentially increasing delays and optional jitter to avoid thundering herds.
Timeout Wrapper
Wrap operations with a timeout to prevent them from hanging indefinitely. Races the operation against a timer.
Bulkhead
Isolate concurrent workloads with execution slots and a bounded queue — prevent one overwhelmed resource from starving others.
Hedged Requests
Fire duplicate requests after a delay and use whichever responds first — tame tail latency by racing redundant calls.
Fallback Strategy
Chain alternative providers to gracefully degrade — try primary, then secondary, cache, and finally a static default.
Caching
LRU Cache
Evict the least recently used item when capacity is reached. O(1) get/put with a hash map + doubly linked list.
LFU Cache
Evict the least frequently used item. Tracks access counts to keep the hottest data in memory.
TTL Cache
Entries expire after a time-to-live. Ensures stale data is automatically purged without manual invalidation.
Cache Aside
Application checks cache first, loads from DB on miss, then populates cache. Most common caching strategy.
Write-Through/Back
Write-through writes to cache and DB synchronously. Write-back buffers writes for eventual persistence.
Cache Stampede
Prevent thundering herd when a popular key expires. Use locking or probabilistic early expiration.
Bloom Filter
Space-efficient probabilistic structure to test set membership. May have false positives but never false negatives.
Load Balancing
Round Robin
Distribute requests sequentially across servers in a circular order. Simple and fair for uniform workloads.
Weighted Round Robin
Assign weights to servers based on capacity. Higher-weight servers receive proportionally more traffic.
Least Connections
Route to the server with the fewest active connections. Adapts to varying request durations.
IP Hashing
Hash client IP to deterministically select a server. Ensures session affinity without shared state.
Consistent Hashing
Map keys to a ring of nodes. Adding/removing nodes only redistributes a fraction of keys.
Messaging
In-Memory Queue
FIFO queue for decoupling producers and consumers. Simple async communication within a single process.
Pub/Sub Broker
Publishers emit events to topics, subscribers receive matching messages. Decouples producers from consumers.
At-Most-Once
Fire and forget delivery. Messages may be lost but are never duplicated. Lowest latency guarantee.
At-Least-Once
Retry until acknowledged. Messages are never lost but may be delivered multiple times.
Dead Letter Queue
Route failed messages to a separate queue for inspection. Prevents poison messages from blocking processing.
Consumer Groups
Distribute partitions across consumers in a group. Enables parallel processing with load balancing.
Partitioned Log
Kafka-style append-only log split into partitions. Ordered within partition, parallel across partitions.
Coordination
Distributed Lock
Ensure mutual exclusion across distributed nodes. Only one process can hold the lock at a time.
Leader Election
Elect a single leader among distributed nodes to coordinate work. Handles failover automatically.
Heartbeat Monitor
Periodic health signals detect node failures. Missing heartbeats trigger failover or deregistration.
Service Registry
Central catalog where services register their endpoints. Enables dynamic discovery of available instances.
Service Discovery
Clients query the registry to find healthy service instances. Supports client-side or server-side patterns.
Consistency
Primary-Replica
One primary handles writes and replicates to read replicas. Scales reads but introduces replication lag.
Read/Write Quorum
Require W writes and R reads where W+R > N for strong consistency. Tunable consistency-availability trade-off.
Vector Clocks
Track causal ordering of events across nodes. Detect concurrent updates and resolve conflicts.
CRDT Counters
Conflict-free replicated data types that converge without coordination. Increment/decrement across replicas.
Consensus
Two Phase Commit
Coordinator asks all participants to prepare, then commit. Atomic but blocking if coordinator fails.
Three Phase Commit
Adds a pre-commit phase to reduce blocking. Participants can safely abort if coordinator is unreachable.
Simplified Raft
Leader-based consensus: elect a leader, replicate logs, commit when majority acknowledges. Understandable by design.
Storage
Key-Value Store
Simple get/put/delete interface backed by a hash map. Foundation of most distributed storage systems.
Append-Only Log
Immutable sequential writes. Fast writes, natural audit trail, basis for event sourcing and WAL.
Write Ahead Log
Log mutations before applying them. Enables crash recovery by replaying the log after restart.
SSTable
Sorted String Table: immutable, sorted key-value file with an index for fast lookups.
LSM Tree
Log-Structured Merge Tree: buffer writes in memory, flush to sorted files, merge in background.
Observability
Metrics Collector
Collect counters, gauges, and rates from your services. Aggregate and expose for monitoring dashboards.
Histogram
Track value distributions with configurable buckets. Compute percentiles (p50, p95, p99) from observations.
Structured Logger
Emit JSON log lines with consistent fields. Enables machine-parseable, searchable, and filterable logs.
Trace ID Propagation
Propagate a unique trace ID across service boundaries. Correlate logs and spans for distributed tracing.
Security
JWT Validation
Decode and verify JSON Web Tokens. Validate signature, expiry, issuer, and claims without shared state.
API Key Validation
Authenticate requests via API keys. Simple, stateless auth for service-to-service communication.
Idempotency Key
Deduplicate requests using a unique key. Safely retry operations without causing duplicate side effects.
HMAC Verification
Verify message integrity and authenticity using a shared secret. Detect tampering in webhooks and APIs.