This module contains HTTP client benchmark harness using [JMH].
Each benchmark class has a set of default JMH configurations tailored to HTTP client performance testing and you might need to adjust them based on your test environment such as increasing warmup iterations or measurement time in order to get more reliable data.
There are three ways to run benchmarks.
- Using the executable JAR (Preferred usage per JMH site)
mvn clean install -P quick -pl :http-client-benchmarks --am
java -jar target/http-client-benchmarks.jar Apache5Benchmark
java -jar target/http-client-benchmarks.jar -wi 3 -i 3 -f 1
- Using
mvn exec:execcommands to invokeUnifiedBenchmarkRunnermain method
mvn clean install -P quick -pl :http-client-benchmarks --am
mvn clean install -pl :bom-internal
cd test/http-client-benchmarks
mvn exec:exec
The UnifiedBenchmarkRunner provides a comprehensive comparison between different HTTP client implementations:
- Apache4: Apache HttpClient 4.x baseline
- Apache5-Platform: Apache HttpClient 5.x with platform threads
- Apache5-Virtual: Apache HttpClient 5.x with virtual threads
The runner executes all benchmark variations, prints metrics to console, and publishes results to CloudWatch metrics for monitoring and analysis.
Each benchmark implementation tests the following operations:
simpleGet: Single-threaded GET operationssimplePut: Single-threaded PUT operationsmultiThreadedGet: Multi-threaded GET operations (10 threads)multiThreadedPut: Multi-threaded PUT operations (10 threads)
- Java 8+: Required for running the benchmarks (as specified by
<javac.target>8</javac.target>) - Java 21+: Required for virtual threads support (Apache5-Virtual benchmarks)
Note: Virtual threads are a preview feature in Java 19-20 and became stable in Java 21. The Apache5-Virtual benchmarks require Java 21 or later.