Why akka http is slow using ab benchmark (without -k flag)?


Disclaimer: I understand that ab is not that right utility to measure requests performance (https://groups.google.com/forum/#!topic/akka-user/yt3QXBXq6zg).

We’re currently investigating the right platform to build web servers and I’m super curious to understand why akka http is slow compared to other stacks like Go or NodeJS.

We’re using simple ab benchmark for 10k requests:
ab -T application/json -p post.json -c 1 -n 10000 <TARGET_SERVICE>
with simple POST route that returns complete("OK")

With these benchmarks, Akka Http shows 30% performance with average requests near ~700req/sec compared to Go/NodeJS ~2k req/sec

It’s obvious that with ab's-k` flag Akka Http speed-ups quickly simultaneously with other platforms.
My question is here: is it possible to make some tuning/optimization for the current benchmark to have more requests/sec?

ab without -k means a new connection for every request. Akka HTTP is rather optimized/designed for a scenario with multiple interactions per connections (since even just setting up a TCP connection is pretty high overhead) and will materialize a server flow for each connection, that flow then keeps running for the entire lifespan of the connection, which is what makes the multiple interaction part so much faster.

The important part here is that using the same connections for multiple requests is how HTTP clients tend to do things, do you have a use case where you would only have a single request per connection that you are benchmarking for?

1 Like

Yes, IoT is a good case here. When you have a lot of mobile devices that sends you 1 request per some event daily or even per hour. We’ve choosed Golang/fasthttp to serve that needs.