System Design
System Design
Day 1: Basics
What is System Design?
System design is the process of defining the architecture, components, modules,
interfaces, and data for a system to satisfy specific requirements.
What is HTTP?
HTTP (HyperText Transfer Protocol) is the foundation of data communication
on the web, facilitating the transfer of resources like HTML pages.
1
What are Relational Databases?
Relational databases store data in structured tables with predefined schemas
and use SQL for querying.
What is a Cache?
A cache is a high-speed data storage layer that stores a subset of data, typically
transient, to serve future requests faster.
What is Thrashing?
Thrashing occurs when a system spends more time swapping data between
memory and disk than executing actual tasks, often due to insufficient memory.
2
Day 2: Load Balancing
What is Load Balancing?
Load balancing is the process of distributing network or application traffic across
multiple servers to ensure no single server becomes a bottleneck, improving
performance and reliability.
What is Sharding?
Sharding is a database partitioning technique that divides large databases into
smaller, faster, and more easily managed parts called shards, often used in
NoSQL databases to improve scalability.
3
Day 3: DataStores
What are Bloom Filters?
Bloom filters are probabilistic data structures used to test whether an element
is a member of a set, allowing for false positives but not false negatives, and are
space-efficient.
Database Migrations
Database migrations involve applying incremental changes to the database schema,
such as adding or altering tables and indexes, without affecting the existing data.
4
Day 4: Consistency vs. Availability
What is Data Consistency?
Data consistency ensures that data remains accurate, valid, and in sync across
all nodes in a distributed system after any operation.
5
Day 5: Message Queues
What is a Message Queue?
A message queue is a form of asynchronous communication protocol where mes-
sages are stored in a queue until they are processed by the receiving application,
enabling decoupled systems.
6
Day 6: DevOps Concepts
What is a Single Point of Failure?
A single point of failure is a component in a system that, if it fails, will cause
the entire system to fail, making it critical to design for redundancy and fault
tolerance.
7
Day 7: Caching
What is Distributed Caching?
Distributed caching stores cached data across multiple servers to improve scal-
ability, fault tolerance, and access speed, ensuring data is closer to the applica-
tion.
Write Policies
Write policies in caching determine how data is written to the cache, with
common strategies being write-through (synchronously writes to cache and
database) and write-back (writes to cache first, then to the database).
Replacement Policies
Replacement policies define how cached data is evicted when the cache reaches
capacity, with strategies like LRU (Least Recently Used), FIFO (First In, First
Out), and LFU (Least Frequently Used).
8
Day 8: Microservices
Microservices vs. Monoliths
Microservices are small, independent services that communicate over a network,
offering flexibility and scalability, while monoliths are single, unified applications
with tightly coupled components.
9
Day 9: API Gateways
How are APIs designed?
APIs are designed by defining the endpoints, request/response formats, authen-
tication methods, and rate limits, focusing on providing a clear, consistent, and
efficient interface for consumers.
10
Day 10: Authentication Mechanisms
OAuth
OAuth is an open standard for token-based authentication, allowing third-party
services to access user information without exposing credentials, often used for
single sign-on.
11
Day 11: System Design Tradeoffs
Pull vs. Push
Pull: The client requests updates or data periodically.
Push: The server sends updates or data to the client as soon as they are
available.
12
Day 12: Practice Problems
13
System Design of a Live-Streaming App
Approach:
1. Architecture: Use a distributed architecture with a combination of a
central server and a Content Delivery Network (CDN) to handle the
streaming and distribution of video content efficiently.
2. Ingestion: Capture live video from broadcasters, encode it into multiple
formats to support various devices and bandwidths, and push the streams
to the CDN.
14
System Design of Instagram
Approach:
1. Architecture: Use a microservices architecture to handle different func-
tionalities like user management, photo storage, feed generation, and no-
tifications.
2. Photo Storage: Store photos in a distributed storage system like Ama-
zon S3 or a similar object storage service, with a CDN to serve images
quickly.
15
System Design of Tinder
Approach:
1. Architecture: Implement a microservices architecture to handle different
services like user profile management, matching, messaging, and notifica-
tions.
2. Matching Algorithm: Use an efficient matching algorithm that consid-
ers user preferences and location, possibly incorporating machine learning
for improved recommendations.
16
System Design of WhatsApp
Approach:
1. Architecture: Use a microservices architecture to handle various features
like messaging, media sharing, user management, and notifications.
17
System Design of TikTok
Approach:
1. Architecture: Use a microservices architecture to handle different func-
tionalities such as video uploading, processing, feed generation, and user
management.
2. Video Processing: Implement a video processing pipeline that includes
encoding, thumbnail generation, and storage in a distributed file system.
3. Feed Generation: Use machine learning algorithms to generate person-
alized video feeds for users based on their interests and interaction history.
4. Database: Use a NoSQL database like DynamoDB for storing user data,
video metadata, and interaction logs.
5. Caching: Cache popular videos and user profiles to reduce database load
and improve response times.
6. CDN: Use a CDN to deliver video content efficiently to users around the
world, minimizing latency.
18
System Design of an Online Coding Judge - Part 1
Approach:
1. Architecture: Use a microservices architecture to separate components
like code submission, compilation, testing, and user management.
19
System Design of an Online Coding Judge - Part 2
Approach:
1. Concurrency: Implement a task queue system to handle multiple con-
current submissions, ensuring that each submission is processed indepen-
dently.
2. Scalability: Scale the compilation and testing services horizontally to
handle large numbers of submissions, especially during coding contests.
3. Leaderboard: Implement a leaderboard system to rank users based on
their performance, updating it in real-time during contests.
4. Database: Use a NoSQL database to store submission results and user
rankings, ensuring quick read/write operations.
5. Caching: Cache frequently accessed data like user rankings and problem
statements to reduce database load.
20
System Design of UPI Payments
Approach:
1. Architecture: Use a distributed microservices architecture to handle
transactions, user authentication, and payment processing.
21
System Design of IRCTC
Approach:
1. Architecture: Use a microservices architecture to handle booking, pay-
ment processing, seat allocation, and user management.
22
System Design of Netflix Video Onboarding Pipeline
Approach:
1. Architecture: Use a distributed microservices architecture to handle
video ingestion, encoding, storage, and distribution.
23
System Design of Doordash
Approach:
1. Architecture: Use a microservices architecture to handle order place-
ment, routing, delivery management, and user notifications.
24
System Design of Amazon Online Shops
Approach:
1. Architecture: Use a microservices architecture to handle various aspects
of the platform, including product search, inventory management, user
accounts, and payment processing.
2. Product Search: Implement a search engine optimized for fast retrieval
of products based on keywords, categories, and filters.
3. Inventory Management: Design a real-time inventory management
system that updates stock levels as orders are placed, ensuring accuracy.
4. Database: Use a combination of SQL and NoSQL databases to manage
product details, user accounts, and transaction history.
5. Scalability: Use auto-scaling and load balancing to handle large volumes
of user traffic, especially during peak shopping seasons.
25
System Design of Google Maps
Approach:
1. Architecture: Use a distributed architecture to handle geospatial data
processing, real-time navigation, and user interaction.
26
System Design of Gmail
Approach:
1. Architecture: Use a microservices architecture to manage user accounts,
emails, storage, and spam filtering.
6. Security: Ensure the security of user accounts and emails through en-
cryption, two-factor authentication, and regular security audits.
27
System Design of a Chess Website
Approach:
1. Architecture: Use a microservices architecture to handle user accounts,
matchmaking, game logic, and real-time gameplay.
2. Game Logic: Implement the chess game logic in a stateless service that
can be scaled horizontally to handle multiple games concurrently.
3. Real-Time Gameplay: Use WebSockets or gRPC to enable real-time
communication between players, ensuring low-latency gameplay.
28
System Design of Uber
Approach:
1. Architecture: Use a microservices architecture to handle user accounts,
driver management, ride matching, and payments.
29
System Design of Google Docs
Approach:
1. Architecture: Use a microservices architecture to manage document
creation, editing, collaboration, and storage.
30