Benchmarks
A basic HTTP benchmarks against @benzene/http
and popular GraphQL Server libraries using rakyll/hey.
http
is preferred over express
where applicable because express
adds overhead (See fastify/benchmarks).
Results are taken after a 5s warm-up. Then the following command is used.
hey -c 100 -z 8s -D body.txt -T application/json -m POST http://localhost:4000/graphql
Remember, this benchmark is for reference only and by no means says that one is better than the others. The slowest part of the application is still the application code itself, not the library.
How to use
Clone the repository, go to benchmarks folder, and install the dependencies.
git clone https://github.com/hoangvvo/benzene.git
cd benzene/benchmarks
npm i
Run the benchmarks (for Windows, use git bash):
Set permissions:
chmod u+x ./run
chmod u+x ./runall
Run benchmarks:
./run <library>
The following can be used as <library>
:
benzene-jit-http
(@benzene/http
with JIT runtime)benzene-http
(@benzene/http
)apollo-server
mercurius
(with JIT)graphql-yoga
graphql-helix
express-graphql
To run all benchmarks at once:
./runall
Create a PR to add one.
To create a markdown table from the result:
./runall > results.txt
node hey-to-table.js
Result
Machine: Linux 5.17.0-051700-generic x86_64 | 12 vCPUs | 16GB Node: v18.7.0
Library | Requests/s | Latency |
---|---|---|
benzene-jit-http | 18605.6566 | 0.0054 |
mercurius | 15734.2445 | 0.0064 |
benzene-http | 11131.1607 | 0.009 |
graphql-yoga | 6410.0653 | 0.0156 |
apollo-server | 3992.5057 | 0.025 |
graphql-helix | 2456.5316 | 0.0406 |
express-graphql | 2138.087 | 0.0466 |