Skip to content
Laviyx Learn

Try

System Design Cheat Sheet

Interview steps, quick numbers, availability, load balancing, caching, databases, consistency, replication, queues, APIs, reliability patterns and common designs.

Updated

Interview steps#

StepTimeGoal
Requirements5 minFeatures, scale, what matters most
Estimates5 minQPS, storage, read-write ratio
API and data5 minEndpoints and tables
High-level design10 minDraw the request path
Deep dive15 minBottlenecks and failures
Wrap up5 minTrade-offs and next steps

Quick numbers#

ItemValue
Seconds in a dayAbout 100,000 (86,400)
1 million requests a dayAbout 12 per second
Peak traffic2 to 5 times the average
Memory read100 ns
SSD read100 microseconds
Round trip in a data centre0.5 ms
Continent to continent150 ms

Availability#

TargetDowntime a year
99%3.65 days
99.9%8.8 hours
99.99%53 minutes
99.999%5.3 minutes

Chained parts multiply: 99.9% × 99.9% = 99.8%.

When to reach for what#

ProblemTool
Too many readsCache, read replicas, CDN
Too many writesSharding, queues, batching
Slow queriesIndexes, denormalise
Slow requestsQueue the work, go async
Traffic spikesQueue, autoscaling, rate limits
Single point of failureRedundancy, failover
Large filesObject storage and CDN
Full-text searchSearch engine
Global usersCDN, regional deployment

Load balancing#

AlgorithmGood for
Round robinSimilar requests
Least connectionsRequests of varied length
IP hashKeeping a client on one server

Layer 4 routes by IP and port. Layer 7 routes by URL and headers.

Caching#

StrategyOn write
Cache-asideUpdate the database, delete the cache entry
Write-throughUpdate cache and database together
Write-backUpdate the cache, and the database later
ProblemFix
StampedeLock, early refresh
AvalancheRandom TTLs
PenetrationCache "not found", Bloom filter
Hot keyLocal cache, copies

Databases#

TypeExamplesUse for
RelationalPostgreSQL, MySQLTransactions, joins
Key-valueRedis, DynamoDBSessions, simple lookups
DocumentMongoDBFlexible records
Wide-columnCassandraHuge write volumes
SearchElasticsearchText search
GraphNeo4jRelationships

Consistency#

  • CAP: during a partition, choose consistency or availability.
  • Quorum: R + W must be greater than N for current reads.
  • Strong: payments, inventory.
  • Eventual: feeds, likes, counters.

Replication and sharding#

  • Replicas add read capacity, not write capacity.
  • Asynchronous replication means lag.
  • A shard key needs many values, and an even spread.
  • Consistent hashing moves few keys when servers change.

Queues#

  • At-least-once delivery means that consumers must be idempotent.
  • Use a dead-letter queue for repeated failures.
  • Queue: tasks. Log (Kafka): event streams and replay.

API#

  • Name resources, and use HTTP methods.
  • Use cursors for feeds.
  • Use idempotency keys for payments.
  • Status codes: 200, 201, 400, 401, 403, 404, 429, 500, 503.

Reliability patterns#

PatternPurpose
TimeoutDo not wait forever
Retry with backoff and jitterSurvive brief failures
Circuit breakerStop calling a failing service
BulkheadContain a failure
Load sheddingDrop less important work
Graceful degradationOffer a reduced service

Rate limiting#

AlgorithmNote
Fixed windowSimple, but allows bursts at edges
Sliding windowAccurate
Token bucketAllows controlled bursts

Common designs#

SystemKey ideas
URL shortenerBase62 IDs, cache, redirects
ChatWebSockets, sequence numbers, wide-column store
News feedFan-out, hybrid for celebrities
VideoChunked upload, transcoding, CDN
Ride-sharingGeo index, in-memory locations, atomic matching
Ticket bookingAtomic holds, unique constraint, waiting room

Want the full explanations? Go to the Learn System Design course →