System Design Template / Approaches Flashcards
Learn patterns for how to approach system design
What are the 6 sections for system I need to include?
(1) Feature Expectations (5 min)
(2) Performance Estimations (5 min)
(3) Design Goals (5 min)
(4) High level design - core building blocks (5-10 min)
(5) Design Deep Dive (important sections) (15-20 min)
(6) Justify Design (5 min)
What should you cover in feature expectations?
(1) Use cases
(2) Scenarios that will not be covered
(3) Who will use
(4) How many will use
(5) Usage patterns
What should you cover in performance estimations?
(1) Throughput (QPS for read and write queries)
(2) Latency expected from the system (for read and write queries)
(3) Read/Write ratio
(4) Traffic estimates
- Write (QPS, Volume of data)
- Read (QPS, Volume of data)
(5) Storage estimates
(6) Memory estimates
- If we are using a cache, what is the kind of data we want to store in cache
- How much RAM and how many machines do we need for us to achieve this ?
- Amount of data you want to store in disk/ssd
What should you cover in design goals?
(1) Latency and Throughput requirements
(2) Consistency vs Availability [Weak/strong/eventual => consistency | Failover/replication => availability]
What should you cover in High Level Design?Q
You should define the core components of the system here from a high level:
(1) APIs for Read/Write scenarios for crucial components (2) Database schema (3) Basic algorithm (4) High level design for Read/Write scenario
What should you cover in the design deep dive?
You should dive deep on a core feature of the system (ask the interviewer to determine what)
Cover the following:
- How to scale the algorithm
- Scaling the individual components - availability, scalability, consistency of each component (consistency and availability patterns)
- Cover the following components and how they would fit in:
- DNS
- CDN (push vs pull)
- Load balancers (where to use them, active/passive, algorithm, layer 4 or 7)
- Reverse proxy
- Application layer scaling (microservices, service directory, etc.)
- Database approach
-> Relational vs NoSQL
-> High level schemas for data and tables
-> RDBMS -> master-slave, master-master, federation, sharding, Denormalization, SQL tuning
-> or NoSQL -> Key-value, wide column, Graph, Document, Fast lookups (
RAM -> Redis, Memcached
AP -> Cassandra, RIAK, Voldemort
CP -> Hbase, Mongo, Couchbase, DynamoDB
Caches -> Client caching, CDN caching, Webserver caching, Database caching, Application caching, Cache @Query level, Cache @Object level
Eviction policies of cache:
»_space; Cache aside
»_space; Write through
»_space; Write behind
»_space; Refresh ahead
Asynchronism -> message queues, Task queues, Back pressure
Communication protocol:
- TCP
- UDP
- REST
- RPC
What should you justify at the end of the system design?
(1) Throughput of each layer
(2) Latency caused between each layer
(3) Overall latency justification
What are the high level components of the system design that should be included in your interview?
- Storage - Database, database schema, and caching strategy
- Network traffic (load balancer, routing strategy, distributing requests)
- Vertical vs Horizontal Scaling strategy
- Data replication and scaling strategy - sharding
- Content Delivery Network (CDN)
- Stateless web tier / stateless architecture
- Data centers
- Message queue / producer/consumer service if needed
Latency for L1 cache reference
0.5 ms
Latency for branch mispredict
5 ns
Latency for L2 cache reference
7 ns
Latency for Mutex unlock/lock
100 ns
Latency for main memory reference
100 ns
Latency for Compress 1K bytes with Zippy
10,000 ns
Latency for Sending packet CA to Netherlands to CA
150 ms