Building Blocks
Reusable distributed-systems primitives — DNS, load balancers, caches, queues, search, monitoring. Every real-world design is a composition of these.
When an interviewer says "design a system that does X", they expect you to assemble building blocks, not invent new ones. Knowing each block's contract (what it guarantees, what it doesn't, what it costs) lets you move quickly through the high-level design and spend the bulk of the time on the genuinely interesting trade-offs.
The building-block pages each follow the same template: use cases, FRs, NFRs, high-level design, detailed design, trade-offs. Read them as reference cards — you don't need to memorize them, but you should be able to recognize when each one is the right hammer.
Key concepts
- Caches are the highest-leverage primitive: a hit-rate jump from 70% to 95% turns most read-heavy workloads from hard to easy
- Queues decouple producers from consumers in time — at the cost of ordering guarantees you have to reason about
- Load balancers come in two flavors: L4 (TCP-level, fast, no app awareness) and L7 (HTTP-level, slower, can route by header/path)
- Sequencers solve the surprisingly hard problem of monotonic global IDs across machines
- Rate limiters protect downstream services from coordinated abuse — every public API needs one
Reference template
// Building-block writeup template
## Use cases
## Functional requirements
## Non-functional requirements
## High-level design
## Detailed design
## Trade-offs
## Real-world examples
## Related building blocks Adapt to your problem; the structure is the load-bearing part.
Common pitfalls
- Picking a building block by reputation rather than fit — Redis isn't the answer to every caching question
- Forgetting that every building block adds an operational surface (deployment, monitoring, on-call)
- Underestimating the cost of cross-region replication — it dominates the latency budget for global designs
- Treating message queues as databases — they're not durable storage for query-back patterns
Related topics
Items (18)
- Domain Name System (DNS)
Hierarchical name resolution, caching, TTL trade-offs, and DNS as a load-balancing primitive.
Building Block Foundational - Load Balancers
L4 vs L7, global vs local, algorithms (round-robin, least-connections, consistent-hash), placement tiers.
Building Block Foundational - Databases
Relational vs document vs wide-column vs graph: when each shape fits, and the trade-off triangle.
Building Block Foundational - Key-Value Store
Consistent-hash ring, replication factor, versioning (vector clocks), failure detection. Dynamo-style design.
Building Block Intermediate - Content Delivery Network (CDN)
Edge caching, origin shielding, push vs pull, cache invalidation, signed URLs.
Building Block Intermediate - Sequencer
Globally-ordered unique IDs with causality. Snowflake, TrueTime, hybrid logical clocks.
Building Block Advanced - Distributed Monitoring
Metrics, logs, traces — the three pillars and the data structures that scale each.
Building Block Intermediate - Server-Side Error Monitoring
Real-time error capture, deduplication, alerting, blast-radius scoping.
Building Block Intermediate - Client-Side Error Monitoring
Browser and mobile error capture, sampling, PII scrubbing, beacon transport.
Building Block Intermediate - Distributed Cache
Memcached vs Redis, sharding, eviction policies, replication, stampede protection.
Building Block Intermediate - Distributed Messaging Queue
FIFO vs at-least-once vs exactly-once, partitions, consumer groups, dead-letter queues.
Building Block Intermediate - Publish / Subscribe
Topic-based fan-out, ordering guarantees, filtering, retention, and the gap between pub-sub and queues.
Building Block Intermediate - Rate Limiter
Cap request rates per client to protect downstream services. Token bucket vs leaky bucket vs sliding window, with the gotchas of distributed coordination.
Building Block Intermediate - Blob Store
Object storage with metadata indexing: chunking, replication, lifecycle, multipart uploads.
Building Block Intermediate - Distributed Search
Inverted indexes, sharded indexing, replication, query fan-out, ranking pipelines.
Building Block Advanced - Distributed Logging
Log shipping, structured fields, aggregation, retention tiers, search-on-logs vs metrics.
Building Block Intermediate - Distributed Task Scheduler
Priority, idempotency, deduplication, retry policies, resource capacity allocation.
Building Block Advanced - Sharded Counters
Decompose a hot counter into N shards and aggregate on read — the canonical fix for write hotspots.
Building Block Intermediate