Comprehensive guide to system design cheatsheet covering architecture, implementation, testing, and operational patterns for production engineering teams.
System design is the art of turning requirements into scalable, reliable, and maintainable infrastructure. This cheatsheet guides engineers through the essential decisions, tools, and patterns for designing systems that work under real load—when the database slows, the network flaps, and the service fails in production. It is not a tutorial, but a field manual: use it during design sessions, architecture reviews, and on-call rotations.
Start with a clear statement of what the system must do. Write the requirements in user-centric, measurable terms.
Use the S.M.A.R.T. criteria implicitly: Specific, Measurable, Achievable, Relevant, Time-bound. Do not assume. Ask:
Break the system into distinct parts:
Map components to services using Service Contracts:
200 OK for success 201 Created after insert 400 Bad Request with error details in {"error": "invalid_field", "details": "name must be non-empty"} 429 Too Many Requests with Retry-After header 503 Service Unavailable with X-Backoff headerSelect a deployment pattern based on traffic and risk tolerance.
/health endpoint. Use feature flags to control rollout:
/api/v1/users/{id} only for users with feature_flag: "new-user-api". {
"user_id": 123,
"name": "Alice",
"features": {
"new-user-api": true,
"dark-mode": false
}
}
CREATE TABLE users (id SERIAL PRIMARY KEY, email VARCHAR(255) UNIQUE, created_at TIMESTAMPTZ); {
"user_id": 123,
"profile": {
"name": "Alice",
"preferences": {
"theme": "dark",
"notifications": ["email", "push"]
}
},
"last_login": "2024-03-15T10:00:00Z"
}
ALTER TABLE users ADD COLUMN bio TEXT; to evolve schema.user_id: user_id % 16 = 0 → DB0 user_id % 16 = 1 → DB1 SELECT * FROM users WHERE user_id = 123; SELECT * FROM users WHERE id = 123; → read from replica INSERT INTO users (email) VALUES ('[email protected]'); → write to primary SELECT * FROM users; → read from replica UPDATE users SET name = 'Bob' WHERE id = 123; → write to primary ping every 1s). UPDATE pg_settings SET value = 'on' WHERE name = 'read_only';Use message queues (Kafka, RabbitMQ, Amazon SQS) to decouple components.
{
"event_type": "user_registered",
"user_id": 123,
"timestamp": "2024-03-15T10:00:00Z"
}
/api/v1/queue/consume {"ack_id": "abc123", "status": "processed"} errors/dead-letter queue X-Message-Id, X-Redelivered, X-Attempts headersGET /api/v1/users/123 → cache key: user:123 EXPIRE user:123 3600 (1 hour) Cache-Control: public, max-age=3600 PURGE /images/avatar.jpg PUT /api/v1/users/123: user:123 in Redis GET /api/v1/users/123 → return cached data TTL and TTL + refresh-on-readGET /api/v1/users/123 with timeout 5s X-Request-ID for tracing across services {
"timestamp": "2024-03-15T10:00:00Z",
"level": "error",
"service": "user-api",
"request_id": "abc123",
"message": "Failed to fetch user from database",
"error": {
"type": "DatabaseError",
"code": "500",
"details": "Connection timeout after 5000ms"
}
}
GET /health → return {"status": "UP", "version": "1.2.0"} circuit_breaker:
failure_threshold: 5
timeout: 1000
retry_attempts: 3
retry_delay: 200
half_open_threshold: 2
GET /api/v1/orders/456 → fails 5 times → open circuit 503 Service Unavailable immediately {"timestamp": "2024-03-15T10:00:00Z", "level": "info", "service": "api", "event": "user_login", "user_id": 123, "ip": "192.168.1.1"} journalctl --follow --unit=api.service level=error AND service=payment AND timestamp>2024-03-15T09:00:00Zhttp_requests_total{method="GET", route="/api/v1/users"} 1234 http_request_duration_seconds{method="POST", status="201"} 0.123 rate(http_requests_total[5m]) > 100 → high request rate avg_over_time(http_request_duration_seconds{method="GET"}[1h]) > 1s → slow APItrace_id span with span_id, operation, start, end, tags trace_id: abc123
span_id: 1
operation: "HTTP GET /api/v1/users/123"
start: 2024-03-15T10:00:00.123Z
end: 2024-03-15T10:00:00.345Z
tags: { user_id: 123, client: "mobile" }
span_id: 2
operation: "Database query: SELECT * FROM users WHERE id = $1"
start: 2024-03-15T10:00:00.200Z
end: 2024-03-15T10:00:00.300Z
tags: { query: "SELECT * FROM users WHERE id = 123" }
traceparent: 00-abc123-123456-01 tracestate: user_id=123,session_id=xyztrace_id, request_id, user_id error object with code, message, details snake_case for JSON fieldscurl -v http://api.example.com/health HTTP/1.1 200 OK Content-Type: application/json {"status": "UP", "version": "1.2.0", "uptime": 3600}request and event labels API → REST/GraphQL DB → PostgreSQL Queue → Kafka Cache → Redis LB → nginxThis is the system design cheatsheet. Use it to build systems that are not just functional, but resilient, observable, and ready for growth.
This page was rewritten on 18 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.
We use cookies for analytics (Google Analytics) and advertising (Google AdSense) to improve your experience and support free content. Privacy Policy