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-serverPull the prebuilt Docker image directly from Docker Hub:
docker pull sid2512/web-serverRun the container
docker run -p 8080:8080 sid2512/web-serverUsing 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
