This repository tests memory consumption and performance between Bun and Node.js when running an Express server. Follow the instructions below to set up and run the test.
Node.js (Node.js Installation)
Bun (Install via the command below)
curl -fsSL https://bun.sh/install | bash
TypeScript (Install globally if needed)
npm install -g typescript
Plow for load testing (Install via cargo)
cargo install plow
git clone https://github.com/ThePrimeagen/bun-vs-node.git
cd bun-vs-node
Install Dependencies
npx tsc
The run
script starts the server using Bun or Node and monitors memory usage at 1-second intervals.
chmod +x run
./run bun bun
./run node node
These commands will start the server and track memory usage, saving the results to bun.mem
and node.mem
, respectively.
We recommend using plow
to perform load tests on the server. For example:
plow http://0.0.0.0:45001 -m POST -c 1000 -n 100000 \
--body @src/tests/medium.json -T 'application/json' \
--no-clean -H "x-method: json"
- -c 1000: Sets 1000 concurrent connections.
- -n 100000: Sends 100,000 requests.
- --body @src/tests/medium.json: Sends the contents of the medium.json file as the request body.
- -T 'application/json': Sets the content type to JSON.
- -H "x-method: json": Sets the x-method header, necessary to specify the test method.
After running the tests, compare the output files (bun.mem
and node.mem
) to evaluate memory usage for each platform. You can also review the performance metrics generated by plow to assess throughput and latency.