System Design Template
Features
- Use cases
- Features we don’t care about
- Who will use this service?
- How many people will use this service?
- How will this service be used?
Estimations
- Throughput (QPS for R/W)
- Maximum tolerated latency for (R/W)
- R/W ratio
- Traffic estimate
- Write (Memory usage)
- Read (Memory usage)
- Storage estimates
- Memory estimate
- Cache usage
- RAM usage
- Disk usage
Design Goals
- Latency and Throughput requirements
- Consistency vs Availablility (Weak/strong/eventual consistency | failover/replication availability)
High Level Design
- APIs for Reads and writes
- Database Schemas
- Algorithms
- High level design for R/Ws
Deep Dive
- Scaling Algorithm
- Scaling components
- Availability and Consistency scaling for each component
- Components:
- DNS
- CDN (Push vs Pull)
- Load Balancers (Active-Passive, Active-Active, Layer 4, Layer 7)
- Reverse Proxy
- Application layer scaling (Services)
- DB (RDBMS, NoSQL)
- RDBMS:
- Leader-Follower, Leader-Leader, Federation, Sharding, Denormalization, Indexing, Tuning
- NoSQL:
- Key-Value, Wide-Column, Graph, Document
- Fast Lookups:
- in RAM: (Bounded size): Redis, Memcached
- Available: (on Disk): Cassandra
- Consistent: DynamoDB
- Caching:
- Client caching, CDN caching, Webserver caching, Database caching, Application caching, Cache @Query level, Cache @Object level
- Eviction policies: - Cache aside - Write through - Write behind - Refresh ahead
- Async
- Message Queues
- Back pressure
- Task Queues
- Communication Protocols
- Justification
- Throughput of each layer
- Latency caused by each layer
- Overall latency justification