Benchmark methodology
GritvsExpress

Grit vs Express

Express is the default answer for "I need a JSON API in Node". This measures it with raw `pg` and no ORM, which is Express at its fastest: whichever ORM you would have reached for makes it slower, not faster.

Node 22, Express 5, cluster, Prisma · v5 + Prisma

What you should end up with

ScenarioGritExpressRatio
show
GET /api/v1/products/:id
8,509 req/s
4.5 ms · neither saturated
982 req/s
55.1 ms · its own ceiling
8.66×
write
POST /api/v1/products
5,126 req/s
7.5 ms · neither saturated
748 req/s
72.8 ms · its own ceiling
6.85×
list
GET /api/v1/products?page=N&page_size=20
861 req/s
46.8 ms · database-bound
280 req/s
168.7 ms · its own ceiling
3.08×
mixed
a weighted blend of the three above
763 req/s
51.5 ms · database-bound
297 req/s
151.5 ms · its own ceiling
2.57×

Both figures come from the same run, minutes apart. Your absolute numbers will differ (different CPU, different disk, different background load) and so will ours: Grit's single-row read measured 4,536 req/s in the Bun pair and 8,509 in the Express pair from an identical binary, as hours of write scenarios accumulated in Postgres. The ratio is what should survive. If it does not, something in the setup differs and the steps below are where to look.

How Express is kept from being handicapped

A benchmark is only worth publishing if the loser was given every reasonable advantage. These are the specific decisions made for this framework, and each one is worth saying out loud on camera.

  • One worker per CPU via `cluster`. Node is single-threaded; running one process on a 4-CPU container while Go schedules goroutines across all four would be a strawman rather than a comparison.
  • Prisma, not raw `pg`. Grit’s generated handlers use GORM and you cannot swap that out, so measuring Express against hand-written SQL would compare an ORM to no ORM, which flatters Express for a reason that has nothing to do with Express. Prisma is what most Node teams actually reach for, and it makes this framework-plus-ORM against framework-plus-ORM.
  • NODE_ENV=production, no request logger. A log line per request is real I/O and every other framework here has it off.
  • Connection pool max of 100, matching every other framework in the comparison.

Reproduce it, start to finish

  1. 1

    Install the two tools you need

    Docker runs every app and the database. k6 generates the load. Nothing else is required: you do not need Go, PHP, Python, Node or Bun installed locally, because every framework builds inside a container.

    # macOS
    brew install k6
    # Windows
    winget install k6 --source winget
    # Linux
    sudo gpg -k && sudo gpg --no-default-keyring \
    --keyring /usr/share/keyrings/k6-archive-keyring.gpg \
    --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
    echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" \
    | sudo tee /etc/apt/sources.list.d/k6.list
    sudo apt-get update && sudo apt-get install k6
    k6 version
    docker --version
  2. 2

    Clone the harness

    Everything below lives in the benchmarks directory of the Grit repository: the compose file, the k6 script, the seed data, and each framework’s application.

    git clone https://github.com/MUKE-coder/grit.git
    cd grit/benchmarks
  3. 3

    Start Postgres and create the databases

    One Postgres instance is shared by every framework, tuned once, with 8 CPUs: deliberately more than any application gets, so the database is never what gives out first. Each framework gets its own database so their schemas cannot collide.

    docker compose up -d postgres
    for db in bench_grit bench_encore bench_bun bench_express bench_nextjs bench_laravel bench_django; do
    docker compose exec -T postgres psql -q -U bench -d bench -c "CREATE DATABASE $db;"
    done
  4. 4

    Create the table and load identical rows

    This is the single most important step for a fair result. Every framework gets the same table, created from the same SQL file, holding the same 10,000 rows with the same UUIDs. Letting each ORM run its own migration would mean comparing schemas, not frameworks: Eloquent, Django and GORM disagree about integer widths, timestamp precision and which columns get indexed.

    for db in bench_grit bench_encore bench_bun bench_express bench_nextjs bench_laravel bench_django; do
    docker compose exec -T postgres psql -q -U bench -d $db < seed/schema.sql
    docker compose exec -T postgres psql -q -U bench -d $db < seed/products.sql
    done
    # every one should print 10000
    for db in bench_grit bench_encore bench_bun bench_express bench_nextjs bench_laravel bench_django; do
    docker compose exec -T postgres psql -tA -U bench -d $db -c "SELECT count(*) FROM products;"
    done

    If any of these prints something other than 10000, stop and fix it. A benchmark where one side has more rows than another is measuring the row count.

  5. 5

    Look at the Express app

    express-bench/server.js is about 180 lines and does exactly what Grit’s generated handler does: same page size and cap, same searchable columns, same sortable allow-list, same envelope. cluster.js forks one server per CPU.

    cat express-bench/server.js
    cat express-bench/cluster.js
  6. 6

    Note the type coercion, and why it is required

    Prisma returns Decimal objects for numeric(12,2) and BigInt for bigint, so precision is not lost passing through JavaScript. Every other framework here emits them as plain JSON numbers, and BigInt cannot even be serialised by JSON.stringify, so this is required rather than cosmetic.

    const shape = (r) => ({
    ...r,
    price: r.price === null ? null : Number(r.price), // Decimal -> number
    stock: r.stock === null ? null : Number(r.stock), // BigInt -> number
    version: Number(r.version),
    created_at: r.createdAt, // camelCase -> snake_case
    updated_at: r.updatedAt,
    })
  7. 7

    Build and start it

    Node 22 on Alpine, four cluster workers. The build runs `prisma generate` against the shared schema before pruning dev dependencies: the generated client is what the server imports at runtime.

    docker compose build express
    docker compose up -d express
    # should print: express-bench: forking 4 workers
    docker compose logs express | head -3
  8. 8

    Check every framework is on an ORM, not raw SQL

    This is the fairness decision that matters most after the shared schema. Grit’s generated handlers use GORM and you cannot swap that out, so measuring any framework against hand-written SQL compares an ORM to no ORM, which flatters that framework for a reason that has nothing to do with it. Express on raw pg measured 2,000 req/s on writes; the same Express on Prisma measured 773. Same framework, same machine, same test.

    # Grit GORM apps/api/internal/models/product.go
    # Laravel Eloquent laravel-bench/app/Models/Product.php
    # Django Django ORM django-bench/products/models.py
    # Express Prisma express-bench/prisma/schema.prisma
    # Next.js Prisma nextjs-bench/prisma/schema.prisma
    # Bun Drizzle bun-bench/schema.ts
    # Encore Drizzle encore-bench/products/schema.ts
    grep -rl "prisma|drizzle|Eloquent|models.Model" express-bench nextjs-bench bun-bench encore-bench django-bench laravel-bench 2>/dev/null | head

    If you swap any of these for raw SQL the numbers move enough to change the conclusion. That is the single easiest way to make this benchmark say whatever you want it to say.

  9. 9

    Prove the two apps return the same bytes

    Before measuring anything, confirm the framework you are testing returns exactly what Grit returns for the same record. If the payloads differ, say a missing field or a price as a string instead of a number, then the two are doing different amounts of work and the comparison is void.

    ID=$(python -c "import json;print(json.load(open('seed/ids.json'))[0])")
    for app in grit express; do
    echo "--- $app"
    docker run --rm --network benchmarks_default curlimages/curl -s \
    "http://$app:8080/api/v1/products/$ID"
    echo
    done

    This is the step most benchmarks skip, and it is the one that decides whether the rest means anything. Show it on camera.

  10. 10

    Run the benchmark

    Three repetitions of four scenarios, one application at a time with the others stopped. Each run resets the dataset first, discards a warm-up, and samples container CPU while the load is actually running.

    APPS="grit express" REPS=3 ./final.sh
    python aggregate.py

Reading your own results

Express is the fastest of the JavaScript runtimes here on writes and holds up well on single-row reads. Watch the CPU column in the aggregate output: if Express is pinned near 400% then you are seeing its real ceiling.

aggregate.py prints the app container's CPU and Postgres's CPU next to every row. That pair is what tells you whether a number is a real ceiling. If the app is pinned near 400% then you are seeing its limit. If the app is idling while Postgres is near 800%, the database gave out first. That row is a floor, the framework would go faster on a bigger database, and quoting it as “X does N req/s” overstates what you measured.

The other guides