Web frameworks benchmarks

Nikolay Kim
2 min readDec 16, 2017

--

This is totally unscientific and pretty useless. In real world, business
logic will dominate on performance side in any case. I just needed some base line for my work on actix optimization. In any case, i took several web frameworks for rust and used simple hello world example for testing.

List of frameworks:

I also tried susanoo, it looks interesting but too slow. also tried tk-http, but it is not a framework and it is not very fast, no reason to use it.

I ran all tests on my MacBook Pro with 2.9Gh i7 with 4 physical cpus and 8 logical cpus. As a testing tool i used wrk and following commands

wrk -t20 -c100 -d10s http://127.0.0.1:8080/

wrk -t20 -c100 -d10s http://127.0.0.1:8080/ -s ./pipeline.lua — / 128

Some notes about benchmarks.

All projects are compiled with release parameter.

I got best performance for sync frameworks with 8 threads, other number of threads always gave me worse performance. Iron could handle piplined requests with lower performace. Interestingly, Rocket completely failed in pipelined test.

There are two reasons why i tested pipelined request. First, it is just fun to see this huge numbers of processed requests :) Second, it is kind of pre-requisite for HTTP/2.0 support.

For asynchronous frameworks i wanted to see how multithreading influence performance, but multithreading is actually harder than i expected. For example I couldn’t find out how to run Gotham in mutiple threads. Seems it just assumes developer need to come up with the way how to run it themselves. On other hand is Shio, i could run it in multiple threads, but there is no difference with 1 thread performance. Maybe something is wrong with how macOS handle reuse address socket option?. Also, I had to modify shio to make it support “http pipeline”.

Each result in this table is best of five runs. All measurements are in req/sec.

Absolute winner is tokio-minihttp. Which is makes sense, it doesn’t do too much. But it is good reference point.

All hello world projects could be found here.

--

--