Hacker News new | ask | show | jobs
by lpgauth 5034 days ago
According to my simple 'hello world' AB test, elli is about 40% faster than cowboy.
2 comments

Cowboy developer here. A good part of that is the lack of the Date header. The other main difference is the lack of routing (that you are going to do in any real-world application anyway). Also depends on your Cowboy version, the one that uses Ranch (which I'm about to push) got an increase in performance due to the removal of a bottleneck.
Hi Löic,

I feel I need to address this, as your two points about why there is a performance difference is false.

I just implemented and released a middleware to add the Date header, it's available here: https://github.com/knutin/elli_date. When running the "Hello World!" micro-benchmark where I'm only testing the performance of the webserver itself, there is no significant difference in performance. I used the same approach as in Cowboy and Yaws and cache the date string in an ETS-table and read it on every request.

As for routing, Cowboy offers very nice routing that makes writing applications easier. Elli does not offer any explicit facility to do this, but pushes it to the user, which in our case typically means function clauses matching on the url as can be seen in this example: https://github.com/knutin/elli/blob/master/src/elli_example_... The Erlang VM can nicely optimize matching on these clauses especially with HiPE. Claiming that Elli and the benchmark does not do any routing is false.

I have studied Cowboy closely and taken ideas from it. I'm very thankful of everybody in the community and you in particular who offers up their projects and ideas for general consumption. It makes the community richer. Building on the shoulders of giants makes projects like Elli easier.

I'm happy that with Ranch, Cowboy will see a performance improvement. I hope that there are some ideas in Elli that can be used by other projects to improve performance and robustness.

Knut

Why is it so much faster? Is it really that much better code, or are there some tradeoffs in the other ones that Elli approaches in a different way?
Less features... still isn't doing dates (which is a known slowdown in Erlang)... connection process because handler process...

Still neat.. what impressed me was some of the linked "helper" projects for doing stuff likes stats.

He wrote a custom webserver based on his very specific needs. It's not a general purpose solution, so not too surprising it's faster for his particular use cases.
It'd be interesting to hear about that in more detail - what tradeoffs he made to get that speedup.