Skip to content

Latest commit

Β 

History

History
119 lines (83 loc) Β· 2.31 KB

File metadata and controls

119 lines (83 loc) Β· 2.31 KB

πŸš€ High-Performance C++ Web Server with Load Balancing and LRU Cache

A multi-threaded web server written in modern C++ featuring:

  • Round-robin load balancing
  • Thread-safe LRU caching
  • Static file serving
  • Docker support
  • Built from scratch using POSIX sockets and threads

πŸ”„ System Flow Chart

System Architecture Flow Chart


πŸ“¦ Project Structure

web-server/
β”œβ”€β”€ src/                  # Core source files
β”‚   β”œβ”€β”€ main.cpp          # Entry point with server setup
β”‚   β”œβ”€β”€ web_server.hpp    # Backend HTTP server
β”‚   β”œβ”€β”€ proxy_server.hpp  # Caching proxy & load balancer
β”‚   β”œβ”€β”€ lru_cache.hpp     # Thread-safe LRU implementation
β”‚   └── load_balancer.hpp # Round-robin dispatcher
│── index.html            # Example homepage(html/css)
β”œβ”€β”€ Makefile              # Build configuration
β”œβ”€β”€ Dockerfile            # Container setup
└── README.md             # This file

πŸš€ Features

βœ… Multi-threaded Architecture
βœ… Intelligent Load Balancing
βœ… LRU Caching (5,000+ entries)
βœ… Static File Support
βœ… 26,000+ req/sec throughput
βœ… Docker-ready Deployment


πŸ”§ Quick Start

Local Build (Manually)

git clone https://github.com/sidd2512/web-server.git
cd web-server
make && ./web-server

Run with Docker

Pull the prebuilt Docker image directly from Docker Hub:

docker pull sid2512/web-server

Run the container

docker run -p 8080:8080 sid2512/web-server

Test Endpoint

Using curl:

curl http://localhost:8080/

Or open in your web browser:

http://localhost:8080/

πŸ“ˆ Benchmark

Tested with wrk:

wrk -t4 -c100 -d10s http://localhost:8080/
Metric Result
Requests/sec 26,422
Avg Latency ~3.5 ms
Backends 3
Cache Size 5,000 entries
Transfer Rate 16.08 MB/s
Cache Hit Rate 92% (warm)

πŸ› οΈ Technology Stack

  • C++17 (STL containers, threading)
  • POSIX sockets (TCP networking)
  • LRU cache (std::unordered_map + list)
  • Round-robin load balancing
  • Docker for containerization

πŸ“œ License

MIT License Β© 2025 Siddharth Kumar