Land the job you want — prepare
with Real interviews Q&A
Curated interview questions, company-wise guides and coding rounds. Practice mock interviews, improve with feedback, and track your progress.
System Design is the process of designing the architecture, components, modules, databases, APIs, and infrastructure of a software application.
It focuses on how large-scale applications handle millions of users, manage data efficiently, maintain performance, scalability, security, and reliability.
In interviews, System Design evaluates your ability to build scalable and production-ready systems like YouTube, WhatsApp, Netflix, Uber, Instagram, etc.
Main Goals of System Design- Scalability
- High Availability
- Reliability
- Performance Optimization
- Security
- Fault Tolerance
Scalability is the ability of a system to handle increasing traffic, users, or data without affecting performance.
A scalable system can grow efficiently when demand increases.
Types of Scalability- Vertical Scaling (Scale Up)
- Horizontal Scaling (Scale Out)
Vertical scaling means increasing CPU, RAM, or storage in the same server.
Horizontal scaling means adding multiple servers to distribute the load.
Load Balancing is the process of distributing incoming network traffic across multiple servers to improve performance and availability.
A load balancer prevents a single server from becoming overloaded.
Benefits- Improves performance
- Prevents server crashes
- High availability
- Fault tolerance
Client → Load Balancer → Multiple Servers
const servers = [
"Server-1",
"Server-2",
"Server-3"
];
let index = 0;
function getServer() {
const server = servers[index];
index = (index + 1) % servers.length;
return server;
}
console.log(getServer());
console.log(getServer());
console.log(getServer());Caching is the process of storing frequently accessed data in fast storage so that future requests can be served quickly.
Instead of repeatedly fetching data from the database, the system first checks the cache.
Advantages- Faster response time
- Reduced database load
- Improved performance
- Better user experience
const cache = {};
function getUser(id) {
// Check cache first
if (cache[id]) {
console.log("Data from cache");
return cache[id];
}
// Simulate database call
console.log("Data from database");
const user = {
id,
name: "AK"
};
cache[id] = user;
return user;
}
getUser(1);
getUser(1);Rate Limiting controls how many requests a user or client can make within a specific time period.
It protects systems from abuse, spam, brute-force attacks, and server overload.
Use Cases- Login APIs
- Payment APIs
- Public APIs
- OTP systems
const requests = {};
function rateLimiter(ip) {
const limit = 5;
if (!requests[ip]) {
requests[ip] = 1;
} else {
requests[ip]++;
}
if (requests[ip] > limit) {
console.log("Too many requests");
return false;
}
console.log("Request allowed");
return true;
}
rateLimiter("192.168.1.1");Microservices architecture divides a large application into multiple small independent services.
Each service handles a specific business functionality and communicates through APIs.
Examples- User Service
- Payment Service
- Notification Service
- Order Service
- Independent deployment
- Easy scalability
- Fault isolation
- Technology flexibility
// User Service
app.get("/users/:id", (req, res) => {
res.send({
id: req.params.id,
name: "AK"
});
});
// Order Service
app.get("/orders/:id", (req, res) => {
res.send({
orderId: req.params.id,
amount: 500
});
});Database sharding is a technique used to split large databases into smaller parts called shards.
Each shard stores a portion of the data to improve scalability and performance.
Benefits- Faster queries
- Reduced load
- Better scalability
- Distributed storage
Shard 1 → Users 1 - 1000
Shard 2 → Users 1001 - 2000
Shard 3 → Users 2001 - 3000
function getShard(userId) {
if (userId <= 1000) {
return "Shard 1";
}
if (userId <= 2000) {
return "Shard 2";
}
return "Shard 3";
}
console.log(getShard(1500));WebSocket is a communication protocol that provides full-duplex communication between client and server.
Unlike HTTP, WebSocket keeps the connection open for real-time data transfer.
Real-time Use Cases- Chat applications
- Live notifications
- Online gaming
- Stock market updates
const socket = new WebSocket("ws://localhost:8080");
socket.onopen = () => {
console.log("Connected");
};
socket.onmessage = (event) => {
console.log("Message:", event.data);
};
socket.send("Hello Server");