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
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
✅ Multi-threaded Architecture
✅ Intelligent Load Balancing
✅ LRU Caching (5,000+ entries)
✅ Static File Support
✅ 26,000+ req/sec throughput
✅ Docker-ready Deployment
git clone https://github.com/sidd2512/web-server.git
cd web-server
make && ./web-server
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
Using curl:
curl http://localhost:8080/
Or open in your web browser:
http://localhost:8080/
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) |
- C++17 (STL containers, threading)
- POSIX sockets (TCP networking)
- LRU cache (std::unordered_map + list)
- Round-robin load balancing
- Docker for containerization
MIT License © 2025 Siddharth Kumar