DEV Community

Arash
Arash

Posted on

3

Nestjs : Bun vs Nodejs

Bun vs Node: A Simple HTTP Server Comparison

This is a brief comparison of running a simple nestjs HTTP server using two different JavaScript runtimes: Node.js and Bun.

Setting Up the NestJS Application

First, I created a basic NestJS application by running the following command:

nest new cloud-bot

To start the server using the Node.js runtime, I ran:

pnpm start

For benchmarking, I used a tool called wrk to measure the server’s performance. Here’s the result when running the server on Node.js:

Image description

The result is fairly decent for a basic “Hello World” application.

Running the Server with Bun

Next, I ran the same server using Bun with the following command:

bun run src/main.ts

Here’s the benchmark result for Bun:

Image description

As you can see, Bun is approximately 4x faster in this “Hello World” API benchmark.

Conclusion

While Bun shows impressive speed improvements for a simple setup, I encountered several issues when trying to use it in a more complex, real-world application. Due to these challenges, I decided to switch back to Node.js for the time being.

If you’re wondering whether Bun is better than Node, it has great potential, especially with its fast package manager. However, Bun needs more updates and releases to reach the maturity level of Node.js.

I hope this helps anyone considering switching to Bun!

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay