Hi all,
I've been trying to write an http 1.1 server in Rust however I have found that, regardless of my approach, performance is quite poor.
I have tried several libraries and even implemented a bare-bones http server using TCPListener
.
- Hyper
- Actix
- May http
- tokio::TCPListener directly
- std::TCPListener directly
- may::TCPListener directly
And compared it to servers written in Go and Nodejs.
Rust seems to outperform in cases where we have few clients that make a large number of requests on sockets they reuse (5 sockets with 50k requests)
A more realistic scenario is many clients making few requests, generating a large number of new socket connections (50k users making 5 requests)
Under these conditions, across all the libraries and approaches I have tested - my Rust servers have high error rates, poor latency and poor throughput.
In some cases Rust exhibits this bizarre pause/surge behavior - video here: Imgur: The magic of the Internet
I'm building with LTO and release flags and have reproduced this on several computers (all running Linux) leading me to believe that either I'm doing something wrong or that there's something fishy happening.
Can I get some advice please