DEV Community

Cover image for Benchmarking web servers in different languages
Filip
Filip

Posted on

Benchmarking web servers in different languages

Being mainly a JS developer I often find myself testing out new frameworks (new ones pop up every week or so) to find what works best for the next project I do. I mostly worked and tested frontend frameworks, but recently I wanted to try backend development. So I started to look at different options for my next project.

Since I worked only with NodeJS so far I wanted to see how it compares to different JS runtimes (Deno and Bun) and to different languages. So for my research, I chose to test Deno, Bun, Go, Go and Fiber, Rust, and Actix against the ones I know (Node and Express).

Setup

For testing I set everything on my M2 Macbook and installed NodeJS, Deno, Bun, Go, and Rust. The setup was painless for all of them since for everything you just need to run a single command from their website and you are good to go.

I also used a tool called wrk to run the tests. This is an amazing tool to benchmark HTTP requests to your server. I ran it with the following configuration:

  • 8 threads
  • 256 concurrent requests
  • 30-second test duration

I created the simplest web server for every language (+framework) I could find and ran the tests 10 times with the following command:

wrk -t8 -c256 -d30s http://127.0.0.1:8000
Enter fullscreen mode Exit fullscreen mode

Results

After running the results I found some interesting stuff. While I expected Go and Rust to beat all the JS runtimes that didn't happen. Deno was almost as good as Actix, and Bun almost beat Go for the top spot. Sadly NodeJS fell well behind all of them with the worst being Express. Express came dead last being over 10 times slower than Bun, almost 6 times slower than Deno and 5 times slower than raw NodeJS.

Conclusion

While this is in no way a comprehensive comparison it gives me an idea of what to expect when choosing the technology for my next project. The results here may be different depending on what I need for my project. My main takeaway here is that it may be time to start moving away from NodeJS, at least when it comes to backend development.

All the results and scripts can be found here.

Top comments (2)

Collapse
 
gevera profile image
Denis Donici

Would be cool to have a common database for all the projects, like sqlite and see the results

Collapse
 
0x96f profile image
Filip

That's a good idea. I will expand the examples with database access and maybe other things when I have more time. Thanks for the suggestion.