Skip to content

Benchmark hiệu năng

Orbit được đo hiệu năng thực tế so với các framework JS phổ biến: Elysia, Hono, Fastify, Express, NestJS (Express/Fastify). Bộ benchmark hoàn chỉnh nằm trong repo orbit-cli — bạn có thể tải về và tự chạy trên máy của mình.

Yêu cầu

  • Bun ≥ 1.2 (khuyến nghị 1.3.x) — chạy Orbit, Elysia, Hono
  • Node.js ≥ 22.5 — chạy Express, Fastify, NestJS (cần module node:sqlite tích hợp sẵn)
  • autocannon tự tải qua npx ở lần chạy đầu

Cài đặt và chạy

bash
git clone https://github.com/galaxy-orbit/orbit-cli.git
cd orbit-cli/benchmarks
bun install
bun run src/runner.ts --runs=3                 # full suite, best-of-3 (giảm nhiễu)
bun run src/runner.ts --duration=5             # chạy nhanh 5s/scenario
bun run src/runner.ts --scenario=db-sqlite     # một scenario cụ thể
bun run src/runner.ts --connections=50 --duration=5  # tải cao hơn

Kết quả được lưu vào benchmarks/results/ dạng JSON + Markdown, bao gồm cả cold start và bộ nhớ (RSS).

Các kịch bản đo

ScenarioMô tảMức độ
hello-worldJSON response đơn giảnĐơn giản
json-serializationObject lồng nhau phức tạpĐơn giản
path-paramsRoute động /users/:idTrung bình
query-paramsParse nhiều query stringTrung bình
body-parsingPOST với JSON bodyTrung bình
db-sqliteSELECT 1 row thật qua SQLite (bun:sqlite / node:sqlite)Nâng cao
db-listSELECT 50 rows, trả array JSON (~2.7KB/response)Nâng cao
db-insertINSERT thật vào SQLite (prepared statement) + trả rowNâng cao

Kết quả (macOS Intel i5-1038NG7 2.0GHz, 16GB, Bun 1.3.14, Node 26.9, 10 conn × 10s × best-of-3)

Khách quan: mọi framework trong suite đều không bật security headers mặc định (helmet/secure-headers là plugin opt-in) — benchmark chạy Orbit với security: false để cùng điều kiện. Core Orbit vẫn giữ security headers mặc định cho người dùng thật. Số liệu dùng orbit-core 0.2.1, mọi server cùng schema SQLite + prepared statement module-level, mỗi framework dùng SQLite binding native của runtime (bun:sqlite / node:sqlite).

Ghi chú độ chính xác: 2 server NestJS trước đây thiếu endpoint DB (số liệu db-sqlite cũ của NestJS là 404) — run này đã bổ sung endpoint thật, toàn bộ số liệu NestJS dưới đây là dữ liệu DB thật.

Requests/sec — càng cao càng tốt (đậm = cao nhất)

ScenarioOrbitElysiaHonoFastifyNestJS FastifyNestJS ExpressExpress
hello-world31,31526,80429,82523,81323,22710,7417,499
json-serialization28,81631,46328,68718,68221,61710,2969,006
path-params28,44532,59430,03720,27721,87310,1879,975
query-params23,11231,85329,61818,14220,5298,9908,901
body-parsing22,85927,25819,67212,81913,5297,4757,248
db-sqlite27,77135,12925,29421,76623,55615,73014,330
db-list13,97215,37111,5335,5836,7804,6014,534
db-insert17,04912,81517,14211,45912,5396,4067,433

Cold start và bộ nhớ

FrameworkCold startRSS
Hono113ms27.4MB
Orbit133ms25.8MB
Elysia217ms42.4MB
Express526ms59.6MB
Fastify627ms67.4MB
NestJS Fastify925ms81.4MB
NestJS Express1,331ms79.0MB

Orbit nhanh ở đâu?

So với các full framework (cùng tính năng DI + decorators + pipeline + validation)

Orbit thắng 8/8 scenarios — nhanh hơn NestJS Express 1.8–3.1×, hơn NestJS Fastify 1.1–2.1×. Đây là so sánh quan trọng nhất: Orbit cạnh tranh trực tiếp với NestJS ở đúng mặt bằng tính năng, nhưng throughput cao hơn hẳn và cold start nhanh ~7× (133ms vs 1,331ms), RSS thấp ~3× (25.8MB vs 79MB).

So với Fastify (framework Node nhanh, không DI): Orbit thắng 8/8, nhanh hơn 1.3–2.5× — đặc biệt ở kịch bản DB nặng: db-list 13,972 vs 5,583 (2.5×), db-insert 17,049 vs 11,459 (1.5×).

So với micro-frameworks (Elysia, Hono)

Elysia/Hono không có DI, decorators, pipeline hay validation — là điểm tham chiếu throughput thuần:

  • Orbit thắng: hello-world (+17% so Elysia, +5% so Hono), db-insert (+33% so Elysia, hòa Hono), body-parsing (+16% so Hono), db-sqlite (+10% so Hono), db-list (+21% so Hono)
  • Elysia nhỉnh hơn: json-serialization (+9%), path-params (+15%), query-params (+38%), db-sqlite (+26%)
  • Kết luận: Orbit thắng Hono 4/8, hòa 1 và chỉ thua Elysia ở 6 scenario serialization thuần với biên độ 9–27% — một sự cân bằng rất sát cho một framework có đủ DI + pipeline, kèm cold start và bộ nhớ thấp nhất bảng.

Released under the MIT License.