tl;dr; Bun is plenty fast to serve as a basic web server that does no I/O. It's even faster than Go using fasthttp.
Doing a "Hello World" benchmark comparison is rather contrived because it's so unrealistic. No server does no I/O. However, it's good to know that if you do need something as simple as this, and need raw performance, you don't need as statically compiled language like Go. Bun is fast enough.
Inspired by this blog post from 2023, I wanted to retry it using Bun 1.3 that came out the other day. Honestly, I was nerdily curious how it would fly on my M4 MacBook Pro.
Check out the code on: https://github.com/peterbe/go-bun-compare
Gist: Bun is slightly faster than Go. By about 15%.
Take it with a pinch of salt. These kinds of benchmarks have flaws because the unrealistic scenario, the lack of logging, and lack of other features such as middleware.
Bonuses
The README has a couple of interesting bonuses such as throwing in Python into the mix.
One that peaked my interest was; how does running a compiled executable, from Bun, compare to running it directly with bun run .... I ran it a bunch of times and noticed that executing it as a single binary made it about 3% faster. Curious!
Comments