# Load Tests Automated benchmarking framework for comparing java-http against other Java HTTP server implementations. ## Prerequisites - **Java 21+** with `JAVA_HOME` set (e.g., `export JAVA_HOME=/opt/homebrew/opt/openjdk@21`) - **Savant** build tool (`sb` on PATH) - **wrk** HTTP benchmark tool (`brew install wrk` on macOS) - **jq** for JSON processing (`brew install jq` on macOS) - **fusionauth-load-tests** (optional) checked out at `~/dev/fusionauth/fusionauth-load-tests` ## Quick Start ```bash # Run all servers, all scenarios, default 30s duration JAVA_HOME=/opt/homebrew/opt/openjdk@21 ./run-benchmarks.sh # Quick smoke test JAVA_HOME=/opt/homebrew/opt/openjdk@21 ./run-benchmarks.sh --servers self --scenarios hello --duration 5s ``` ## Servers Under Test | Server | Directory | Description | |--------|-----------|-------------| | `self` | `self/` | java-http (the project being benchmarked) | | `jdk-httpserver` | `jdk-httpserver/` | JDK built-in `com.sun.net.httpserver.HttpServer` | | `jetty` | `jetty/` | Eclipse Jetty 12.0.x embedded server | | `netty` | `netty/` | Netty 4.1.x with HTTP codec | | `tomcat` | `tomcat/` | Apache Tomcat 8.5.x embedded | All servers implement the same endpoints on port 8080: - `GET /` - No-op (reads body, returns empty 200 response) - `GET /no-read` - No-op (does not read body, returns empty 200 response) - `GET /hello` - Returns "Hello world" - `GET /file?size=N` - Returns N bytes of generated content (default 1MB) - `POST /load` - Base64-encodes request body and returns it ## Benchmark Tools ### wrk (default) C-based HTTP benchmark tool using epoll/kqueue. Very fast, unlikely to bottleneck. Provides percentile latency metrics (p50, p90, p99). ### fusionauth-load-tests Java-based load generator using virtual threads and the JDK HttpClient. Provides a "real Java client" perspective. Gives average latency and RPS but not percentiles. Sends a small request body with each GET request. Set the checkout location via environment variable if not at the default path: ```bash export FUSIONAUTH_LOAD_TESTS_DIR=~/dev/fusionauth/fusionauth-load-tests ``` ## Usage ``` ./run-benchmarks.sh [OPTIONS] Options: --servers Comma-separated server list (default: all) --scenarios Comma-separated scenario list (default: all) --tool Benchmark tool: wrk, fusionauth, or both (default: wrk) --label Label for the results file --output Output directory (default: load-tests/results/) --duration