5 ms·
(Elixir / Erlang) Bandit's HTTP/1.x engine is up to 5x faster
- sph 5y agoThose are very nice figures compared to cowboy which is already plenty fast than similar web servers in other languages. Hope it becomes a valid alternative for Phoenix when this stabilises a little more.
- mcmatterson 5y agoAuthor here. AMA!
- weatherlight 5y agoReally nice work btw!
- fouc 5y agoWhy is Bandit so much more performant than Cowboy? Also why does bandit have a peak around the 32 concurrent connections? Would idiomatic OTP design patterns normally exhibit that kind of behavior?
- mcmatterson 5y agoFundamentally, Bandit just does a lot less work than Cowboy does. Particularly with HTTP/1 requests, Bandit uses a single process per connection in contrast with Cowboy's 2 per connection. This allows Bandit's handler code to be very 'linear' and free of coordination complexity; for the most part, an HTTP/1 connection will go from initial connection to Plug call and back again without having to leave the process at all. More broadly, there's just less functionality in Bandit (by design; it's a very focused library that doesn't need to do a bunch of the stuff that Cowboy does). All that stuff ends up adding up when you're doing it 100k a second. This correlates with Bandit's relative numbers being better in HTTP/1 (up to 5x faster than Cowboy) than they are in HTTP/2 (a paltry 2.3x faster than Cowboy). In terms of the 32 concurrent connections peak, my hunch here is that it's due to the server the test is running on being a 32 core VM (see https://github.com/mtrudel/network_benchmark https://github.com/mtrudel/network_benchmark for details of the benchmarking process). Truthfully I'm no expert with benchmarking & this may not hold a lot of truth; at the end of the day the test is pretty apples to apples so I think it has comparative merit, but the absolute numbers are a bit murkier to me.
- knowmad 5y agoHow does bandit differ from finch and mint?
- mcmatterson 5y agoBandit is an HTTP server, not a client. It performs the same job in the stack as Cowboy does currently (just up to 5x faster as this post's title alludes to). The Bandit project shares a small amount of code with the Mint project (Andrea & Eric were kind enough to factor out their HTTP/2 header compression library for use in Bandit), but this is mostly due to HTTP being a largely symmetric protocol (ie: there is a lot of functionality used equally by both clients and servers).