System Design Examples
Web Server Architecture
What is Web Server Architecture?
It defines how a web application is structured to handle client requests efficiently.
Basic Architecture (3-Tier Architecture)
Flow:
Client → Web Server → Application Server → Database
Components
A. Client Layer
● Browser or mobile app
● Sends HTTP/HTTPS requests
B. Web Server Layer
● Handles incoming requests
● Serves static content (HTML, CSS, images)
Examples:
● Apache HTTP Server
● Nginx
C. Application Server Layer
● Contains business logic
● Processes dynamic requests
Examples:
● [Link]
● Java (Spring Boot)
● Python (Django)
D. Database Layer
● Stores application data
● Handles queries
Advanced Architecture Features
● Load balancer (distributes traffic)
● Caching (Redis, Memcached)
● CDN for faster delivery
● Microservices architecture
Real Example
Opening a website:
1. Browser sends request
2. Nginx receives it
3. App server processes logic
4. Database fetches data
5. Response sent back
Database Server Setup
What is a Database Server?
A system that stores, manages, and retrieves data for applications.
Types of Database Servers
A. Relational Databases (SQL)
● Structured data (tables)
Examples:
● MySQL
● PostgreSQL
B. NoSQL Databases
● Unstructured or flexible data
Examples:
● MongoDB
● Cassandra
Key Database Components
● Query processor
● Storage engine
● Indexing system
● Cache (in-memory data)
Real-Life Example
E-commerce system:
● Product data stored in database
● User searches → query sent
● DB returns results → displayed on website
Web Server + Database Together
Example Flow:
1. Client sends request
2. Web server receives it
3. App server processes logic
4. Database provides data
5. Response returned
Real-Life Analogy
● Web server = Receptionist
● Application server = Manager
● Database = Storage room
Real-World Architecture Case Studies
1. E-Commerce Platform Architecture
Example: Amazon
Web Server Architecture Flow
1. Client searches for a product
2. Request goes to load balancer
3. Routed to web server (e.g., Nginx)
4. Application server processes:
○ Search logic
○ User session
5. Request sent to database
Database Server Setup
● Uses distributed databases
● Product catalog stored across multiple servers
● Caching used for frequently searched items
Key Features
● High scalability
● Fault tolerance
● Fast response using caching
2. Social Media Platform
Example: Facebook
Web Server Architecture
1. User posts a status
2. Request goes to web server
3. Application server handles:
○ Post creation
○ Notifications
Database Setup
● Uses NoSQL databases (e.g., MongoDB)
● Data is distributed globally
● Replication ensures availability
Key Features
● Handles millions of concurrent users
● Fast reads/writes
● Data replication for reliability
3. Video Streaming Platform
Example: Netflix
Web Server Architecture
1. User clicks “Play”
2. Request routed via CDN
3. Web server handles authentication
4. Streaming server delivers content
Database Setup
● Stores:
○ User preferences
○ Watch history
● Uses distributed + cached databases
Key Features
● Heavy use of caching (RAM)
● Global content delivery
● Low latency streaming
4. Banking System Architecture
Example: State Bank of India
Web Server Architecture
1. User logs in
2. Request processed by secure web server
3. Application server performs:
○ Authentication
○ Transaction processing
Database Setup
● Uses relational databases like Oracle Database
● Master-slave replication
● Strong consistency
Key Features
● High security (encryption)
● ACID transactions
● Reliable data storage
5. Ride-Sharing System
Example: Uber
Web Server Architecture
1. User requests a ride
2. Request goes to nearest server
3. Application server:
○ Matches driver
○ Calculates fare
Database Setup
● Real-time data stored in memory
● Uses distributed databases
● Location tracking handled continuously
Key Features
● Real-time processing
● Location-based services
● High availability
Common Patterns Across All Case Studies
Web Server Side
● Load balancing
● Multiple web servers
● Application logic separation
Database Side
● Replication
● Sharding (data splitting)
● Caching
Overall Flow
Client → Load Balancer → Web Server → Application Server → Database → Response