Home

Awesome

Bun HTTP Framework Benchmark

Compare throughput benchmarks from various JavaScript HTTP framework

Test method: Average throughput

  1. Ping
    • Request to [GET] /
    • Return hi
    • Headers must contains text Content-Type: text/plain, additional context is acceptable eg. Content-Type: text/plain; charset=utf-8
  2. Query
    • Request to [GET] /id/:id
    • Extract path parameter, query string and setting headers.
    • For this benchmark, the request URL will be send as: /id/1?name=bun
    • Headers must contains x-powered-by to benchmark
    • Expected response: "1 bun" (${id} ${query})
      • You MUST NOT use hardcode string or index to extract querystring.
      • In a real-world situation, there's no enforcement that the request will follow the specification, using hardcode index to extract name=bun querystring will be prone to error.
      • To test if it pass the requirement, the implementation should be able to extract querystring dynamically (please treat the value of 'name=bun' can be any value beside 'bun', for example 'alice', 'hina'), which means that the same code should be able to extract querystring, for example:
      • /id/1?name=bun&id=1 -> should return 1 bun not 1 bun&id=1
      • /id/1?id=1 -> should return 1
      • Query beside name maybe not need to be extracted and is optional
    • Headers must contains text Content-Type: text/plain, additional context is acceptable eg. Content-Type: text/plain; charset=utf-8
  3. Body
    • [POST] /json
    • Mirror body to response
    • Server MUST parse body to JSON and serialize back to string
    • For the benchmark, the request body will be sent as: { "hello": "world" }
    • Expected response: { "hello": "world" }
    • Headers must contains text Content-Type: application/json, additional context is acceptable eg. Content-Type: application/json; charset=utf-8.

requirement

Prerequistes

Run Test

bun benchmark

Dump result will be available at results/[benchmark-name].txt

Benchmark Condition

This benchmark is tested under the following condition:

Tested on 8 Sep 2024 05:01 (GMT+7)

Results

These results are measured in req/s:

FrameworkRuntimeAveragePingQueryBody
uwsnode527,699.817541,728.16506,782.5534,588.79
bunbun376,420.943392,717.69328,330.58408,214.56
vixenybun356,834.84385,534.29319,145.22365,825.01
elysiabun352,250.317383,595.46310,593.51362,561.98
hyper-expressnode319,107.997374,450.68302,821.11280,052.2
bun-web-standardbun313,198.2346,600.11266,327.5326,666.99
wobebun311,801.343299,285.73286,038.98350,079.32
bytebun303,735.947375,423.2313,890.35221,894.29
nhttpbun291,237.093386,127.8254,391.47233,192.01
honobun259,255.42301,659.93241,603.06234,503.27
nbitbun238,980.92262,030.93205,738.83249,173
honodeno204,461.127248,811.96201,761.33162,810.09
fastifynode142,272.007156,478.26145,993.88124,343.88
hononode127,262.563141,586.05132,756.96107,444.68
oakbun123,337.233121,435.6111,719.25136,856.85
expressbun121,354.08134,906.43114,388.25114,767.56
koanode104,732.993115,311.99103,595.2695,291.73
oakdeno103,133.703108,901.0697,124.66103,375.39
h3node100,166.14131,867.22115,211.9653,419.24
acorndeno64,043.27793,953.6570,454.1127,722.07
expressnode29,512.10331,004.128,612.8828,919.33

See more detail in results

Notice

I highly recommended testing this benchmark on your machine yourself as performance in likely to vary between machine.