A simple HTTP/1.1 server implementation in pure Java with no external dependencies. Includes three different concurrency models to compare performance characteristics.
- Three server strategies: Single-threaded, thread-per-request, and thread pool
- HTTP/1.1 basics: GET/POST methods, headers, keep-alive, request bodies
- Simple routing: Path-based routing with lambda handlers
- Metrics: Request counts, latency tracking,
/metricsendpoint - Benchmarking: Built-in performance testing with
hey
# Build
mvn clean package
# Run (choose: single, thread, or pool)
java -jar target/httpforge-1.0-SNAPSHOT.jar poolServer runs on http://localhost:8080
GET /- Welcome messageGET /hello- Hello world (20ms simulated delay)GET /echo- Request infoPOST /data- Echo POST bodyGET /metrics- Performance metrics (JSON)
Install hey first:
# macOS
brew install hey
# Linux
go install github.com/rakyll/hey@latest
# Or download from: https://github.com/rakyll/heySome benchmarks:
See more: https://httpforge.vercel.app/
Run benchmarks:
cd benchmarks
./run.sh pool # or: single, thread, or all
cat benchmark-results/pool_c100.txt # view resultshttp/ - HTTP protocol (parser, request, response)
routing/ - Router and route definitions
server/ - Server implementations (single, thread-per-request, pool)
metrics/ - Performance tracking
- Java 11+
- Maven 3.6+
hey(optional, for benchmarks)
- Single-threaded: Minimal resources, handles one request at a time
- Thread-per-request: New thread per connection, higher memory usage
- Thread pool: Best for production, fixed threads with request queue