Showing 30 question(s)

Answer:

System Design is the process of designing scalable, reliable, maintainable, and efficient software systems that meet functional and non-functional requirements.

Code Example:

Client
   |
Load Balancer
   |
Application Servers
   |
Database

Tags:

Answer:

Functional requirements describe what a system should do, while non-functional requirements define performance, scalability, reliability, security, and availability expectations.

Code Example:

Functional:
- User Login
- Search Products

Non-Functional:
- 99.9% Availability
- <200ms Response Time

Tags:

Answer:

Scalability is the ability of a system to handle increasing traffic or workload by adding more resources.

Code Example:

Vertical Scaling
Server ↑ CPU ↑ RAM

Horizontal Scaling
Server1
Server2
Server3

Tags:

Answer:

High Availability ensures a system remains operational even when hardware or software failures occur.

Code Example:

Load Balancer
 /        \
App1     App2

Tags:

Answer:

Fault Tolerance allows a system to continue functioning despite failures in one or more components.

Code Example:

Primary DB
     |
Replication
     |
Replica DB

Tags:

Answer:

Client-Server Architecture separates the client that requests services from the server that processes requests and returns responses.

Code Example:

Client ---> Server

Tags:

Answer:

A monolithic application contains all business logic, UI, and database access in a single deployable unit.

Code Example:

Application
 ├── UI
 ├── Business Logic
 └── Database

Tags:

Answer:

Microservices divide an application into independent services that communicate through APIs or messaging.

Code Example:

API Gateway
 |   |   |
User Product Order

Tags:

Answer:

An API Gateway acts as a single entry point for clients and routes requests to appropriate backend services.

Code Example:

Client
   |
API Gateway
 |   |   |
User Product Payment

Tags:

Answer:

Service Discovery enables services to locate and communicate with each other dynamically without hardcoded addresses.

Code Example:

Service A
    |
Service Registry
    |
Service B

Tags:

Answer:

Horizontal scaling means adding more servers or instances to distribute traffic and improve system capacity.

Code Example:

Users
   |
Load Balancer
 /   |   \
S1  S2  S3

Tags:

Answer:

Vertical scaling increases CPU, RAM, or storage of an existing server instead of adding new servers.

Code Example:

Server
CPU: 4 -> 16
RAM: 8GB -> 64GB

Tags:

Answer:

Caching stores frequently accessed data in memory to reduce database queries and improve response time.

Code Example:

Client
  |
Cache (Redis)
  |
Database

Tags:

Answer:

Common cache eviction policies include LRU (Least Recently Used), LFU (Least Frequently Used), FIFO, and TTL-based expiration.

Code Example:

LRU
LFU
FIFO
TTL

Tags:

Answer:

Database sharding splits data across multiple databases based on a shard key to improve scalability.

Code Example:

Users A-M -> DB1
Users N-Z -> DB2

Tags:

Answer:

Replication copies data from a primary database to one or more replicas for high availability and read scalability.

Code Example:

Primary DB
   |
---------
|       |
Replica Replica

Tags:

Answer:

A load balancer distributes incoming requests across multiple servers to improve availability and performance.

Code Example:

Users
 |
LB
/|\
S1 S2 S3

Tags:

Answer:

Layer 4 load balancers route traffic based on TCP/UDP information, while Layer 7 load balancers route using HTTP request details like URL or headers.

Code Example:

L4 -> TCP/UDP
L7 -> HTTP/HTTPS

Tags:

Answer:

A message queue enables asynchronous communication between services by storing messages until they are processed.

Code Example:

Producer
   |
 Queue
   |
Consumer

Tags:

Answer:

Event-driven architecture allows services to communicate through events instead of direct synchronous requests.

Code Example:

Service A
   |
 Event Bus
 /   |   \
B    C    D

Tags:

Answer:

CAP theorem states that a distributed system can guarantee only two out of Consistency, Availability, and Partition Tolerance at the same time.

Code Example:

CAP
C = Consistency
A = Availability
P = Partition Tolerance

Tags:

Answer:

Eventual consistency means all replicas will eventually contain the same data if no new updates occur.

Code Example:

Write
 |
Primary
 |
Replicas
(Eventually Sync)

Tags:

Answer:

Fault tolerance enables a system to continue operating correctly even when one or more components fail.

Code Example:

Server1 ❌
Server2 ✅
Server3 ✅

Tags:

Answer:

High availability ensures systems remain operational with minimal downtime using redundancy and failover mechanisms.

Code Example:

Load Balancer
 /        \
Server1  Server2

Tags:

Answer:

A Content Delivery Network (CDN) caches static content on geographically distributed edge servers to reduce latency.

Code Example:

User
 |
Nearest CDN
 |
Origin Server

Tags:

Answer:

DNS translates domain names into IP addresses so users can access services using human-readable names.

Code Example:

example.com
     |
 DNS
     |
192.168.x.x

Tags:

Answer:

Monitoring helps track application health, performance, resource utilization, failures, and alerts in production systems.

Code Example:

Application
   |
Prometheus
   |
Grafana

Tags:

Answer:

Distributed tracing follows requests across multiple services to identify latency and failures.

Code Example:

Client
 |
API
 |
Service A
 |
Service B

Tags:

Answer:

CQRS separates read and write operations into different models, improving scalability and performance.

Code Example:

Write Model
     |
Database
     |
Read Model

Tags:

Answer:

Use stateless services, load balancing, caching, asynchronous messaging, database indexing, replication, monitoring, autoscaling, fault tolerance, and secure communication to build scalable and reliable distributed systems.

Code Example:

Users
 |
Load Balancer
 |
App Servers
 |
Cache
 |
Database

Tags: