/spring-boot-2-performance

A simple poc to measure spring boot 2.0 reactive web performance

Primary LanguageJava

spring-boot-2-performance metrics

Starting the server

First step is to build the project and then start the server from terminal.

Gradle build
./gradlew clean build
Start the server
$ cd build/libs
$ java -Xms512m -jar <artifact.jar>

Now the server shall start on port 8080 ready for serving the requests.

Install wrk tool for performance testing

wrk - a HTTP benchmarking tool

wrk is a modern HTTP benchmarking tool capable of generating significant load when run on a single multi-core CPU. It combines a multithreaded design with scalable event notification systems such as epoll and kqueue.

More Information

https://github.com/wg/wrk

Installation on Ubuntu

To install wrk on ubuntu 18.04 system, just run the below command

sudo apt install wrk

Now wrk is ready for the testing.

Benchmarking Metrics

Now start the Spring Boot application and run the below command from terminal

$ wrk -t8 -c40 -d30s http://localhost:8080/api/perf

This will launch 8 threads and keep 40 HTTP open connections for a duration of 30s and measure the results.

wrk output
Figure 1. Benchmark details

My machine is 16GB DDR3, Xeon E31245, 2011 Model Desktop

cpu info
Figure 2. cpu-information

So we can see that a simple ping controller gives throughput of 31000 requests per second, which is not bad at all.

Using h2load for HTTP Benchmarking

h2load is another high performance HTTP benchmarking tool that we can use to bench mark our API.

h2load to send 100000 requests using 50 concurrency level
$ h2load -n100000 -c50 --h1 http://localhost:8080/api/perf
Response
starting benchmark...
spawning thread #0: 50 total client(s). 100000 total requests
Application protocol: http/1.1

finished in 1.61s, 62089.09 req/s, 5.39MB/s
requests: 100000 total, 100000 started, 100000 done, 100000 succeeded, 0 failed, 0 errored, 0 timeout
status codes: 100000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 8.68MB (9100000) total, 4.20MB (4400000) headers (space savings 0.00%), 1.91MB (2000000) data
                     min         max         mean         sd        +/- sd
time for request:      114us     11.88ms       801us       213us    98.82%
time for connect:      204us      3.11ms      1.64ms       817us    58.00%
time to 1st byte:     3.17ms      8.25ms      5.35ms      1.34ms    58.00%
req/s           :    1242.20     1248.13     1244.66        1.22    70.00%

We can see that with latest version of Spring Boot 2.2.0, we can get a throughput of 62K requests/second on the same Ubuntu 18.04.2 server.