8000 GitHub - voidCounter/httpforge: a http server written from scratch in java, bechmarking different execution patterns.
[go: up one dir, main page]

Skip to content

a http server written from scratch in java, bechmarking different execution patterns.

Notifications You must be signed in to change notification settings

voidCounter/httpforge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTTPForge

A simple HTTP/1.1 server implementation in pure Java with no external dependencies. Includes three different concurrency models to compare performance characteristics.

Features

  • 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, /metrics endpoint
  • Benchmarking: Built-in performance testing with hey

Quick Start

# Build
mvn clean package

# Run (choose: single, thread, or pool)
java -jar target/httpforge-1.0-SNAPSHOT.jar pool

Server runs on http://localhost:8080

Endpoints

  • GET / - Welcome message
  • GET /hello - Hello world (20ms simulated delay)
  • GET /echo - Request info
  • POST /data - Echo POST body
  • GET /metrics - Performance metrics (JSON)

Benchmarking

Install hey first:

# macOS
brew install hey

# Linux
go install github.com/rakyll/hey@latest

# Or download from: https://github.com/rakyll/hey

Some benchmarks:

image image image image

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 results

Project Structure

http/       - HTTP protocol (parser, request, response)
routing/    - Router and route definitions
server/     - Server implementations (single, thread-per-request, pool)
metrics/    - Performance tracking

Requirements

  • Java 11+
  • Maven 3.6+
  • hey (optional, for benchmarks)

Performance Notes

  • 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

About

a http server written from scratch in java, bechmarking different execution patterns.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0