edit

Performance

The http4k server-backend modules provide a very thin adapter layer over the raw APIs of the underlying servers, so generally performs at a very low overhead compared to the raw server.

Tech Empower Benchmarks

We have entered http4k into the prominent Tech Empower Framework Benchmarks project, which assesses frameworks over a series of realistic tests.

For this benchmark, no customisation or performance tuning of the underlying servers was done - the default application HttpHandler was used which is then plugged into each custom backend, as below:

fun main(args: Array<String>) {
    Http4kBenchmarkServer.start(Undertow(9000))
}

Command-line JVM options, however, were tuned for the test to take advantage of various JVM features.

The full implementation of the benchmark can be found here.

Results - Round 16

Overall, http4k did very well in this round of benchmarking, especially considering that the ethos of the library is one of excellent Developer experience over and above high-end performance (which tends to result in less friendly APIs).

The big surprise was the high performance of the Apache server backend, which consistently outranked Undertow (which is the the most fully featured of all the supported backends and our default option). The SunHttp backend, which we entered for a baseline comparison, unfortunately didn't produce any results in this round.

For each of the sections below, the rankings are based only on JVM-based entries.

DB query + HTML rendering: results:

Top rank: 11/82 - Apache backend

Database driver used is PostgreSql backed by a Hikari pool. Handlebars templating engine is used for rendering.

Multiple DB queries: results:

Top rank: 3/76 - Jetty backend

Database driver used is PostgreSql backed by a Hikari pool.

Single DB query: results:

Top rank: 7/78 - Apache backend

Database driver used is PostgreSql backed by a Hikari pool.

Random DB updates: results:

Top rank: 11/69 - Jetty backend

Database driver used is PostgreSql backed by a Hikari pool.

JSON Serialization: results:

Top rank: 23/77 - Apache backend

The standard Jackson module is used for JSON creation and marshalling.

Plaintext pipelining: results:

Top rank: 23/73 - Apache backend