// PERFORMANCE

A thin layer over the metal - and it shows.

The http4k server backends are a very thin adapter over the raw server APIs, so they run at very low overhead compared to the bare server. We’ll be straight with you though: our north star is developer experience, not topping a leaderboard. Happily, you rarely have to choose.

// TECH EMPOWER BENCHMARKS

Measured in public, by someone else.

http4k is entered into the TechEmpower Framework Benchmarks - an independent project that runs frameworks through a series of realistic tests. No custom tuning of the underlying servers: the default app HttpHandler is plugged into each backend, exactly as you’d write it.

JVM command-line options were tuned to take advantage of JVM features. The full implementation is public on GitHub.

benchmark.kt
// one HttpHandler, every backend
val app: HttpHandler = routes(
    "/json" bind GET to { Response(OK)
        .with(jsonLens of Message("Hello")) },
    "/plaintext" bind GET to {
        Response(OK).body("Hello, World!") }
)
// plug into Netty, Jetty, Apache...
// RESULTS - ROUND 22

Placing 48/159 overall - and top-half of the JVM pack.

Rankings below are filtered to JVM libraries, best backend shown per test. Each links to the live TechEmpower data. Lower rank is better.

Composite ranking

The headline, all-round score across every test type.

view data →
Top rank
13 / 41 JVM
13/41

By test type

top JVM rank · best backend
DB query + HTML render
25/146
Multiple DB queries
23/145
Single DB query
25/151
Random DB updates
41/138
JSON serialization
59/152
Plaintext pipelining
84/153

Backends & drivers vary per test (Apache, Jetty Loom, Netty; PostgreSQL / Vert.x with a Hikari pool; Rocker templating). See the full Round 22 data.

// THE HONEST BIT

We optimise for developer experience first.

Chasing the very top of a benchmark table tends to produce hostile, un-http4k-like APIs. We'd rather give you friendly, testable, composable code that still lands comfortably in the top half of the JVM pack. For the vast majority of real systems, http4k is nowhere near your bottleneck - your database is.

Benchmark your own app. TechEmpower simulates simple real-world scenarios, but your app can behave drastically differently. If performance is critical, try different engines with your own workload - and remember startup time varies a lot between backends too.

Pick the backend, keep the code.

Swap Netty for Jetty Loom for Apache with one line, and benchmark what actually matters: your app.

scarf