Cowboy Webserver Performance Benchmarks

In this series of articles we benchmark the performance of Cowboy. Then we analyze the root cause of performance degradation in Cowboy 2. We point to some solutions and show their effect on the test results.

Part 1

Part 2

26 Likes

Nice analysis and testing methodology, I enjoyed reading that :slight_smile:

2 Likes

Very interesting. Great job with the analysis and breakdowns.

Is there a possibility of detecting the HTTP type and processing it as needed?

Thanks!

This question should be answered by Cowboy maintainers–they are well aware of this analysis and probably thinking in this direction. For one this can be complicated by the fact that HTTP 1.1 connection can get upgraded to HTTP 2.0.

2 Likes

Nice!!!

Great survey! Tanks!

That was exactly what I noticed over a year ago.
I asked Loïc Hoguin (the author of Cowboy) a question about forced use of HTTP/2 scheme.

Here is the discussion

2 Likes

Here is an issue discussing the regression.

One improvement that appears to be already under way is the active_n stuff, though as Loïc notes in the issue, use of that will require that the minimum version of OTP supported be OTP 21.3 (since that’s when Loïc’s PR adding active_n for ssl was released.)

2 Likes

I would like to share in the community these two interesting articles about elixir benchmarking


As always Elixir doing a very well done job against Go, despite Go doing better in CPU performance.

I hope you guys enjoy

2 Likes

Why the versions of the Cowboy 2x it isn’t better performmed then 1x?

They have made an article about the CPU usage.
Because they were wondering why the BEAM use almost 100% of CPU.

Maybe it’s a good lecture after your first link, to understand the why and how of the results.

2 Likes

Cowboy 2 is defaulting to HTTP 2, while cowboy 1 (and I believe all of the other webservers) were using HTTP 1. I don’t fully know the details, but cowboy 2 was doing some additional work that the others did not have to do. I believe cowboy 2 spawns 2 processes per connection for HTTP 2 and only 1 for HTTP 1. So it was actually a slightly unfair comparison for cowboy 2.

4 Likes

yeah makes sense.
and thank you for reply!

@Ankhers @romenigld more like 1.5 of process per connection. Whole thing is that Cowboy (and Plug by extension) want to have one process per request. In HTTP 1.1 it was simple, as each request created new TCP connection that was dealing with it, after request was done you just dumped process and connection with it. In HTTP 2 things became a little bit weirder, as now (to save time) we can have multiple request over the same connection. Simultaneous requests. So now Cowboy to provide the same API as Cowboy 1 need to spawn 2 processes - one for connection and one per request. This is causing more work (as the connection process need also to know which request goes to which process).

In short that is it.

5 Likes