A minimal, HTTP/1.1 server implementation built from scratch in pure C. Uses raw sockets and thread pool architecture to handle requests with no external libraries.
- Pure C implementation using POSIX sockets
- Optimized delivery responses with average time per request taking 8.70ms.
- HTTP/1.1 Compliant with proper request parsing, response headers and status codes
- High-Performance Multithreading: Utilize POSIX-based thread pool to manage concurrent clients with over 11,500 requests per second in benchmark test.
- Static File serving
- MIME Type Detection for Automatic content-type headers based on file extensions
- Security Hardened preventing directory traversal protection and input validation
Tested using ApacheBench across 50 runs with 100 concurrent clients and request counts ranging from 500 to 1,500. Demonstrating high stability and strong performance.
Only a Few runs showed faliures averaging with 0.06 failed requests per run remaining reliable under sustained loads.
Throughput:
- Avg RPS: 11,507.25 — high and consistent.
- Avg TPR: 8.70 ms — low latency under load.
src/
├── main.c # Entry point and server initialization
├── server.c # Core TCP socket server logic
├── http.c # HTTP/1.1 protocol implementation
└── files.c # Static file serving and MIME handling
include/
├── server.h # Server configuration and structures
├── http.h # HTTP parsing and response functions
└── files.h # File operations and security checks
static/
├── index.html # Default web interface with glassmorphism UI
├── styles.css # Modern CSS styling
└── script.js # Client-side JavaScript functionality
Scripts/
└── ab_bench.py # benchmarking file
Build the server:
make clean && make
Start the server:
./criver
Build the server and run
python3 scripts/ab_benchmark.py --runs 50 --min-requests 500 --max-requests 1500 --concurrency 100 --url http://localhost:8000/
The server will start on http://localhost:8000
or just type localhost:8000
in your browser
- C Compiler (GCC or Clang)
- POSIX-compliant system (Linux, macOS)
- Make build system
- Python (optional if you want to run benchmark)
- Scale to 10k concurrent connections
- Imeplement in-memory caching