π System Design Interview Preparation β Day 1
Today we build the foundation. Don't worry about Redis, Kafka, microservices, sharding, etc. yet. First, you need to understand how to think like a system designer.
Day 1 β System Design Fundamentals
1. What is System Design?
System design is the process of defining the architecture, components, data flow, APIs, databases, and infrastructure required to build a software system that satisfies functional and non-functional requirements.
For example, suppose an interviewer asks:
"Design a URL Shortener like Bitly."
You shouldn't immediately start drawing:
Client β API β DatabaseFirst ask:
- How many users?
- How many URLs?
- How many requests per second?
- How quickly should redirects happen?
- Should the system be available 99.9% of the time?
- How long should URLs be stored?
- Do we need analytics?
System design is primarily about making engineering decisions based on requirements and constraints.
2. HLD vs LLD
This is very important for interviews.
HLD β High-Level Design
Focuses on components and how they communicate.
Example:
ββββββββββββββββ
β Client β
ββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββ
β Load Balancerβ
ββββββββ¬ββββββββ
β
ββββββββββ΄βββββββββ
βΌ βΌ
ββββββββββββ ββββββββββββ
β API β β API β
β Server 1 β β Server 2 β
ββββββ¬ββββββ ββββββ¬ββββββ
β β
ββββββββββ¬βββββββββ
βΌ
ββββββββββββ
β Database β
ββββββββββββHLD discusses:
- Services
- Databases
- Caches
- Load balancers
- Queues
- APIs
- Communication
- Scaling
- Availability
LLD β Low-Level Design
Focuses on classes, interfaces, objects and their interactions.
Example:
public interface IUrlService
{
Task<string> CreateShortUrl(string longUrl);
Task<string> GetLongUrl(string shortCode);
}Then:
UrlController
β
IUrlService
β
UrlRepository
β
DatabaseInterview distinction
| HLD | LLD |
|---|---|
| Architecture | Classes |
| Services | Interfaces |
| Databases | Objects |
| Scaling | Design patterns |
| Load balancing | SOLID |
| Caching | Dependency Injection |
| Message queues | Class relationships |
For your preparation, we'll cover both, but we'll start with HLD.
3. Functional Requirements
Functional requirements describe what the system should do.
Example: You are designing an online shopping system.
Functional requirements:
- User can register.
- User can login.
- User can search products.
- User can add products to cart.
- User can place orders.
- User can make payments.
- User can track orders.
These are the features.
Interview tip
Don't try to design every possible feature.
Ask:
"What are the core functional requirements we should focus on?"
Then define the scope.
4. Non-Functional Requirements
Non-functional requirements describe how well the system should operate.
Examples:
- Scalability
- Availability
- Reliability
- Performance
- Security
- Maintainability
- Consistency
For example:
The system should support 10 million users and maintain 99.9% availability.
That's not a feature.
That's a non-functional requirement.
5. Scalability
Scalability means:
The ability of a system to handle increasing load by adding resources.
Suppose your application currently handles:
1,000 requests/secLater it needs to handle:
100,000 requests/secYour system needs to scale.
There are two major approaches.
Vertical Scaling
Increase the power of a machine.
Before:
4 CPU
8 GB RAM
β
After:
16 CPU
64 GB RAMAdvantages:
- Simple
- Easy to implement
Disadvantages:
- Hardware limit
- Can become expensive
- Single-machine failure remains a concern
Horizontal Scaling
Add more machines.
Load Balancer
/ | \
/ | \
βΌ βΌ βΌ
Server1 Server2 Server3Instead of making one server extremely powerful, add more servers.
This is extremely important for modern distributed systems.
6. Availability
Availability means:
How often the system is operational and accessible when users need it.
For example:
99%
99.9%
99.99%
99.999%These numbers are often called availability percentages.
Approximate annual downtime:
| Availability | Downtime/year |
|---|---|
| 99% | 3.65 days |
| 99.9% | 8.76 hours |
| 99.99% | 52.6 minutes |
| 99.999% | 5.26 minutes |
So:
99.9% availability means the system can theoretically be unavailable for around 8 hours 45 minutes per year.
7. Reliability
Availability and reliability are related but different.
Availability
Is the system available right now?
Reliability
Does the system consistently perform correctly over time?
Example:
A payment service might be available:
99.99%but if it occasionally charges customers twice, it's not sufficiently reliable.
For financial systems, reliability and correctness are critical.
8. Performance
Performance describes how efficiently the system responds to requests.
Two important metrics:
Latency
How long does one request take?
Example:
Request
β
API
β
Database
β
Response
Latency = 100 msThroughput
How many requests can the system process over a period of time?
Example:
10,000 requests/sec9. Latency vs Throughput
This is a common interview question.
Latency
Time taken for a request.
Example:
API request β response
50 msThroughput
Number of requests processed per unit of time.
Example:
50,000 requests/secondThink:
Latency = How fast?
Throughput = How much?
10. The System Design Interview Framework
This is probably the most important thing from Day 1.
Whenever the interviewer gives you:
"Design X"
Don't immediately draw architecture.
Follow this sequence:
1. Requirements
β
2. Scale Estimation
β
3. APIs
β
4. Data Model
β
5. High-Level Architecture
β
6. Detailed Design
β
7. Bottlenecks
β
8. Scaling
β
9. Failure Handling
β
10. Trade-offsLet's understand each.
Step 1 β Requirements
Ask:
What does the system need to do?
Example:
URL Shortener
Create short URL
Redirect short URL
View basic analyticsStep 2 β Scale Estimation
Ask:
How much traffic are we expecting?
Example:
100 million users
10 million URLs/day
100K requests/secYou don't need perfect mathematics.
The goal is to understand the order of magnitude.
Step 3 β APIs
Define major APIs.
Example:
POST /urls
GET /{shortCode}Step 4 β Data Model
Example:
URL
----------------
id
shortCode
longUrl
createdAt
expiresAtStep 5 β High-Level Architecture
Now draw:
Client
β
Load Balancer
β
API Servers
β
Cache
β
DatabaseStep 6 β Deep Dive
Now ask:
What happens when traffic increases?
Maybe:
Cache
Database Replication
Read Replicas
Horizontal ScalingStep 7 β Bottlenecks
Identify potential problems.
Example:
Database becomes overloaded
β
Read replicas
+
CachingStep 8 β Failure Handling
Ask:
What happens if the database goes down?
Possible solutions:
- Replication
- Failover
- Backup
- Retry
- Circuit breaker
We'll study these in later days.
Step 9 β Trade-offs
This is where strong candidates differentiate themselves.
For example:
"We could use SQL because we need strong consistency, but at very large scale a distributed NoSQL database may provide better horizontal scalability. The choice depends on the access pattern and consistency requirements."
Don't simply say:
"We'll use MongoDB because it's scalable."
Explain why.
π― Day 1 Interview Questions
Don't look for answers yet. Try answering them yourself.
Q1.
What is system design? Why is it important?
Q2.
What is the difference between HLD and LLD?
Q3.
What are functional and non-functional requirements? Give examples.
Q4.
What is scalability?
Q5.
What is the difference between vertical and horizontal scaling?
Q6.
What is availability? How is it different from reliability?
Q7.
What is latency? What is throughput?
Q8.
What is the difference between latency and throughput?
Q9.
What questions should you ask before designing a system?
Q10.
Explain the step-by-step approach you would follow when asked: "Design a URL Shortener."
π§ Day 1 Interview Cheat Sheet
Remember these:
System Design
β
Requirements
β
Scale
β
APIs
β
Data
β
Architecture
β
Bottlenecks
β
Scaling
β
Failure Handling
β
Trade-offsAnd:
Functional β What the system does
Non-functional β How well it does it
Latency β Time per request
Throughput β Requests per second
Vertical scaling β Bigger machine
Horizontal β More machines
Availability β System is accessible
Reliability β System works correctly/consistently
HLD β Architecture
LLD β Classes/designYour Day 1 task
Try answering Q1βQ10 in your own words first.