The Ultimate System Design Cheatsheet
Approaching a complex distributed system design interview without a structured playbook is a quick recipe for failure. Many engineers struggle because they either jump straight into drawing boxes, or attempt to memorize static architectures (like "How to design Instagram") without understanding the core physical constraints and architectural tradeoffs that govern high-scale systems.
This cheatsheet serves as an exhaustive, battle-tested quick-reference blueprint. It covers the physical latency numbers every backend developer must know, mathematical capacity estimation formulas, component selection trees, distributed transaction structures, and high-signal trade-offs.
Requirements and System Goals
Every high-performance distributed architecture must be mapped along a standardized structural framework.
1. Functional Requirements
- Structural Component Mapping: Formulate clean pathways to select storage (SQL, NoSQL, Wide-column, Key-value), caches, queues, and proxies based on operational access profiles.
- Granular API Design: Translate system interactions into standard CRUD REST, gRPC streaming, or WebSocket long-lived interfaces.
- Deterministic Back-of-the-Envelope Estimation: Provide templates to convert abstract user engagement targets into precise storage capacity, write/read QPS, and memory requirements.
- Durable Consensus Coordination: Integrate transaction workflows to guarantee data safety across isolated network nodes.
2. Non-Functional Requirements
- High Operational Availability: Target "Four Nines" (99.99%) or "Five Nines" (99.999%) cluster uptime by eliminating all single points of failure (SPOF).
- Ultra-Low Latency Overhead: Enforce microsecond latency limits on critical edge routers, and limit internal microservice network hops.
- Configurable Partition Tolerance: Maintain transaction consistency (CP) or high availability (AP) predictably under constant hardware failure.
- Elastic Resource Scalability: Support horizontal auto-scaling nodes to gracefully absorb massive traffic spikes.
API Interfaces and Service Contracts
Architects translate system interaction diagrams into concrete, strongly typed API schemas using industry-standard protocols.
1. Unified REST API Standard CRUD Pattern
A clean API design enforces standard HTTP methods, strict semantic codes, and payload parameters.
POST /api/v1/resources
Authorization: Bearer <jwt_token>
Idempotency-Key: <unique_uuid>
Content-Type: application/json
Request Payload:
{
"tenant_id": "tenant_codesprintpro",
"resource_details": {
"name": "payment_ledger",
"configuration_type": "HIGH_DURABILITY",
"maximum_concurrency_limit": 5000
}
}
Response Payload (201 Created):
{
"resource_id": "res_88776655",
"status": "PROVISIONED",
"created_at": 1774895600,
"endpoints": {
"primary": "https://ledger-us-east.codesprintpro.com",
"failover": "https://ledger-us-west.codesprintpro.com"
}
}
2. Standard gRPC Bidirectional Streaming Schema
For high-frequency, low-latency client-server synchronization (such as stock feeds or active chats), gRPC bidirectional streaming multiplexes frames over a single TCP connection.
syntax = "proto3";
package cheatsheet.v1;
service TelemetryStreamService {
// Streams real-time connection state events back and forth
rpc SyncTelemetry (stream TelemetryFrame) returns (stream TelemetryAck);
}
message TelemetryFrame {
string session_id = 1;
int64 timestamp_ns = 2;
bytes payload_bytes = 3;
string checksum_sha256 = 4;
}
message TelemetryAck {
string ack_id = 1;
bool success = 2;
int64 server_time_ns = 3;
}
High-Level Design and Visualizations
System design candidates must utilize comprehensive components flowcharts to systematically justify every database and queue selection.
1. The Ultimate Component Selection Decision Tree
This blueprint maps initial client requirements down to specialized, high-performance database and messaging structures.
graph TD
Start[I need to design a component...] --> ReadWrite{Primary Workload?}
ReadWrite -->|1. Storage / Data Store| StorageType{Data Model Semantics?}
ReadWrite -->|2. Traffic Optimization| CachingType{Read Latency Target?}
ReadWrite -->|3. Communication Layer| BrokerType{Coordination Style?}
StorageType -->|ACID Ledger / Complex Joins| SQL[SQL: PostgreSQL / MySQL]
StorageType -->|Ultra-high Writes / Wide-Column| Cassandra[Cassandra / DynamoDB]
StorageType -->|Hierarchical Documents| MongoDB[MongoDB / DocumentDB]
StorageType -->|Spatial Geo-Tracking| RedisGeo[Redis Geo / PostGIS]
CachingType -->|Sub-millisecond Local Cache| Redis[Redis / Memcached]
CachingType -->|Global Static Edge Assets| CDN[CDN: CloudFront / Cloudflare]
BrokerType -->|High Throughput / Replayable Logs| Kafka[Kafka Broker]
BrokerType -->|Complex AMQP Task Routing| RabbitMQ[RabbitMQ]
BrokerType -->|Simple Serverless Queues| SQS[AWS SQS / ActiveMQ]
2. Distributed Microservices Ingress Blueprint
This flowchart illustrates the complete ingress path: a mobile client requests data, which routes through firewalls, load balancers, and caches before hitting persistent databases.
graph TD
Client[Mobile/Web Client] -->|1. SSL Handshake| Route53[Anycast DNS / Route 53]
Route53 -->|2. Resolve IP| CDN[CDN Edge / Cloudflare]
CDN -->|3. Cache Miss / Route WAN| ALB[Application Load Balancer / NGINX]
ALB -->|4. Rate Limit & Auth| GW[API Gateway / Envoy]
GW -->|5. Query Cache| RedisCache[(Redis Cluster)]
GW -->|6. Cache Miss / Invoke API| API[Stateless Use Case Service]
API -->|7. Read/Write| DB[(Relational DB / Sharded Postgres)]
API -.->|8. Asynchronous Event| KafkaQueue[Kafka Event Log]
Low-Level Design and Schema Strategies
To support robust, horizontally partitioned systems, database schemas must implement composited sharding keys and bounded rate-limiting structures at the database layer.
1. Multi-Tenant Session Cache Schema (Redis Key Blueprint)
To guarantee sub-millisecond authentication verification, user sessions are cached in Redis using highly structured, namespace-isolated keys.
Key Pattern:
session:{tenant_id}:{user_id}
Value Type: Hash
Fields:
- "token_sig": "sha256_hash_value"
- "roles": "admin,billing"
- "device_id": "mobile_dev_04"
- "authenticated_at": "1774895600"
2. Dynamic Sliding Window Rate Limiter Schema (PostgreSQL)
This transactional database schema models a resilient, highly precise sliding window rate limiter to protect downstream services from API abuse.
CREATE TABLE rate_limit_windows (
client_identifier VARCHAR(128) NOT NULL,
window_start_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
request_counter INT NOT NULL DEFAULT 1,
PRIMARY KEY (client_identifier, window_start_timestamp)
);
-- Optimize range deletion query performance
CREATE INDEX idx_rate_limit_cleanup ON rate_limit_windows (window_start_timestamp);
Scaling and Operational Challenges
Back-of-the-envelope estimations and hardware numbers form the mathematical foundation of any system design.
1. Latency Numbers Every Software Engineer Must Know
These numbers represent physical constraints. Memorizing them is essential to justifying design decisions during high-scale design discussions.
| Operation | Latency (Time) | Analogy / Conceptual Context |
|---|---|---|
| L1 Cache Reference | 0.5 ns | One human heart beat |
| Branch Misprediction | 5 ns | Stepping slightly off balance |
| L2 Cache Reference | 7 ns | Reaching into a pocket |
| Mutex Lock / Unlock | 25 ns | Flicking a light switch |
| Main Memory Reference (RAM) | 100 ns | Walking across a normal room |
| Compress 1KB bytes with Zlib | 3,000 ns (3 µs) | Writing a single page of text |
| Send 2KB over 1 Gbps network | 20,000 ns (20 µs) | Shouting to a nearby building |
| Read 1MB Sequentially from SSD | 1,000,000 ns (1 ms) | Flying across the country in a jet |
| Round Trip inside Same Datacenter | 500,000 ns (0.5 ms) | Walking to a neighbor's house |
| Read 1MB Sequentially from Disk | 20,000,000 ns (20 ms) | Sailing across a small ocean |
| WAN Cross-Atlantic Round Trip | 150,000,000 ns (150 ms) | Travelling around the globe |
2. The Back-of-the-Envelope Capacity Estimation Formula Guide
System design candidates must instantly convert User counts to exact throughput metrics. Use this math guide:
A. Ingress/Egress QPS Conversions:
- Rule of Thumb: $$1 \text{ Million Daily Active Users (DAU)} \approx 12 \text{ Requests/sec (QPS)}$$
- Proof: $$1,000,000 \text{ Users} \times 1 \text{ req/user/day} = 1,000,000 \text{ reqs/day}$$ $$\text{Seconds per Day} = 24 \times 3,600 = 86,400 \text{ seconds}$$ $$\text{Average QPS} = \frac{1,000,000 \text{ reqs}}{86,400 \text{ seconds}} \approx 11.57 \text{ QPS} \approx 12 \text{ QPS}$$
- Peak QPS Multiplier: For high-traffic events, apply a $3 \times$ to $5 \times$ peak multiplier: $$\text{Peak QPS} = \text{Average QPS} \times 3$$
B. Storage Capacity Accumulation:
- Let us calculate storage for a system capturing 50 Million uploads/day where each payload requires 500 Bytes: $$\text{Daily Storage} = 50,000,000 \text{ uploads} \times 500 \text{ Bytes} = 25,000,000,000 \text{ Bytes} = 25 \text{ GB/day}$$ $$\text{Annual Storage Requirement} = 25 \text{ GB/day} \times 365 \text{ days} \approx 9.1 \text{ TB/year}$$
Trade-offs and Architectural Alternatives
Resilient architecture is a process of picking the correct trade-offs. The tables below compile trade-offs for core system components.
1. Relational SQL vs NoSQL Wide-Column vs NoSQL Key-Value
No database fits every query pattern. Architects select engines based on consistency requirements and scale properties.
| Database Class | Consistency Guarantees | Horizontal Scalability | Schema Flexibility | Best Use Case |
|---|---|---|---|---|
| Relational (PostgreSQL, MySQL) | Strong (ACID) (Strict constraint checking, complex relations) | Poor (Requires sharding or vertical scaling; read replicas are eventually consistent) | Low (Structured DDL tables; migrations require careful execution) | Financial ledgers, payment records, inventory systems, complex entity relationships |
| Wide-Column (Cassandra, DynamoDB) | Eventual (Tunable) (Lacks relational joins; writes scale linearly) | Excellent (Consistent hashing enables linear node scaling) | High (Dynamic columns; schema is flexible but queries are restricted) | High-volume analytical tracking, time-series telemetry, user logs, chat history |
| Key-Value (Redis, Memcached) | Eventual / None (No complex query indexing; fast RAM storage) | High (Redis clustering supports dynamic keyspaces) | Very High (Arbitrary byte strings, hashes, sets, sorted sets) | Session cache databases, fast-path lock registries, rate limit counters |
2. High-Throughput Message Brokers: Kafka vs RabbitMQ
Messaging systems dictate the flow control and decoupling resilience of microservice pipelines.
| Broker Engine | Message Model | Data Durability | Peak Throughput | Client Delivery Model | Best Use Case |
|---|---|---|---|---|---|
| Apache Kafka | Log-based (Messages written to disk partition logs; highly replayable) | Outstanding (Durable, multi-replica disk retention) | Catastrophic (Scale) (Linear write streaming, millions of QPS) | Pull-based (Consumer pulls events in batches at its own pace) | Real-time event sourcing, log processing, big data pipeline analysis |
| RabbitMQ | Memory-based (Messages are routed via exchanges and deleted on ack) | Medium (Can be written to disk, but degrades performance) | Medium (Capped by memory queues; up to 50,000 QPS) | Push-based (Broker actively pushes messages to consumers) | Complex task routing, AMQP wildcard routes, asynchronous workers |
Failure Modes and Fault Tolerance Strategies
High-availability is achieved through proactive incident prevention and resilient recovery strategies.
1. High-Availability "Nines" Cheat Sheet
Architects define acceptable downtime budgets using the "Nines" metric.
- 99% (Two Nines): 3.65 days of downtime per year. Standard hobbyist applications.
- 99.9% (Three Nines): 8.77 hours of downtime per year. Standard business applications.
- 99.99% (Four Nines): 52.6 minutes of downtime per year. Silver MANG tier infrastructure.
- 99.999% (Five Nines): 5.26 minutes of downtime per year. Gold mission-critical infrastructure (telecoms, core banking).
2. The Resiliency Patterns Toolkit
Distributed microservices must implement defensive programming boundaries to survive cascading network partitions.
- Circuit Breaker (Resilience4j):
- The Logic: If downstream service failures exceed a specific threshold (e.g., 50% failures), the breaker trips to the Open State.
- The Result: All subsequent calls fail fast immediately, completely avoiding thread pool saturation and giving the downstream service breathing room to recover.
- Bulkhead Isolation:
- The Logic: Isolate thread pools for different APIs (e.g., separate checkout threads from analytical report threads).
- The Result: If the slow analytical reporting database exhausts its thread pool, the checkout API continues to run cleanly on its isolated pool with zero impact.
- Exponential Backoff with Random Jitter:
- The Logic: Upstream clients wait progressively longer before retrying failed requests, introducing a pseudo-random "jitter" offset to the backoff time.
- The Result: Prevents the Thundering Herd problem by spreading retry request traffic uniformly across time.
Staff Engineer Perspective
[!IMPORTANT] The Golden System Design Interview Playbook (PEDAL) To excel in any system design interview, never jump straight into drawing boxes. Enforce the PEDAL framework strictly over the 45-minute window:
- P - Problem Definition (5 mins): Ask clarifying questions. Enforce functional bounds (what are we designing?) and list explicit non-functional metrics (what is the scale?).
- E - Estimations (5 mins): Execute back-of-the-envelope math. Calculate write/read QPS, peak QPS, storage footprint per year, and memory cache requirements.
- D - Design High-Level (10 mins): Draw the core end-to-end boxes. Route the request from DNS, CDNs, API Gateways, down to stateless apps and primary storage databases.
- A - Architecture Deep-Dive (20 mins): Zoom into the critical bottleneck. Discuss sharding keys, consistent hashing rings, index strategies, data sync CDC, and failure states.
- L - Log & Scale (5 mins): Define observability metrics (tracing, logging) and address load-shedding, backpressure, and redundancy patterns.
Verbal Script
Interviewer: "How would you design a distributed, globally scalable system that handles millions of active checkouts daily, ensuring strong consistency and high availability?"
Candidate: "To design a globally scalable e-commerce checkout platform that guarantees strong consistency and high availability, I will follow the PEDAL framework.
First, let's define our Problem constraints. We must guarantee atomic checkout transactions spanning our payment, inventory, and ledger databases with a zero-tolerance policy for double charging. Our scale targets 100 Million Daily Active Users (DAU).
Applying our Estimation conversions, 100M DAU translates to: $$\text{Average QPS} = 100 \times 12 \text{ QPS} = 1,200 \text{ QPS}$$ Applying a $5 \times$ peak multiplier, our system must handle: $$\text{Peak QPS} = 6,000 \text{ checkout operations/sec}$$
Second, for our High-Level Design, client requests route through Route53 Anycast DNS to our CDN edge nodes (Amazon CloudFront) to instantly serve static catalogs.
Checkout requests route through our Application Load Balancer and API Gateway (Envoy) into our stateless Checkout Microservice.
Third, for the data store, we face the classic CAP theorem trade-off. For checking out, we require strong consistency (CP). We cannot use an eventually consistent NoSQL database because we run the risk of double-allocating inventory or writing mismatched ledger balances.
Therefore, I select a sharded PostgreSQL Relational Database. We shard our accounts using a composite shard key: tenant_id and user_id, and distribute the data across 16 physical shards using Consistent Hashing. This ensures that all checkout writes for a specific user occur within a single physical shard group, allowing us to utilize local relational transactions and avoid slow, blocking distributed 2PC handshakes.
Fourth, to coordinate asynchronous tasks like email notifications and warehouse packing dispatches, we publish events to Apache Kafka. We choose Kafka over RabbitMQ because its log-based, multi-replica partitioning model supports high-throughput write streaming and guarantees message replayability if downstream consumers fail.
Fifth, to protect our hot checkout database from cascading failures during peak events, we implement strict Resiliency Patterns inside our application.
We protect external payment gateway RPC calls using Resilience4j Circuit Breakers configured with a drop-tail bounded queue.
If the payment gateway slows down, the circuit breaker opens to fail fast, preventing thread pool exhaustion in our checkout service.
We wrap all client retry logic with Exponential Backoff and Jitter to break up thundering herd synchronization.
Finally, to manage storage costs, our sharded Postgres databases write transactional state asynchronously via Debezium Change Data Capture (CDC) to our cold data lake. S3 lifecycle policies automatically move inactive records older than 90 days to Glacier Deep Archive, keeping our primary transactional database footprint small and fast."