Benchmarks
hitlimit is designed for performance. Here are real benchmarks you can reproduce on your own hardware.
TL;DR
| Use Case | Recommended Store | Expected Performance |
|---|---|---|
| Single server, high traffic | Memory | 400k+ ops/sec |
| Single server, need persistence | SQLite | 35k+ ops/sec |
| Multiple servers | Redis | 12k+ ops/sec |
| Bun runtime | bun:sqlite | 95k+ ops/sec |
Methodology
All benchmarks follow these principles:
- Reproducible - Anyone can run the same benchmarks
- Fair - Compare apples to apples
- Real - Numbers from actual tests, not estimates
- Documented - Exact hardware, software, and methodology
Test Environment
Machine: MacBook Pro M2 / AWS c6i.xlarge (4 vCPU, 8GB RAM)
Node.js: v20.10.0
Bun: v1.0.20
Redis: 7.2 (Docker)
SQLite: better-sqlite3 v11.0.0 / bun:sqlite (native)
Methodology:
- Each benchmark runs 3 times, median reported
- Warmup: 1,000 requests before measurement
- Test: 100,000 requests (or 10 seconds, whichever first)
- Single-threaded to measure raw library performance
- Memory measured via process.memoryUsage() Store Performance
Memory Store
Best for single-instance deployments where persistence isn't needed.
Memory Store Benchmark (Node.js 20)
400,000+ ops/sec
0.002ms avg latency
0.01ms p99 latency
~50 bytes per key
SQLite Store
Best for single-instance deployments where you need persistence.
SQLite Store Benchmark (Node.js 20, :memory:)
35,000+ ops/sec
0.025ms avg latency
0.15ms p99 latency
Redis Store
Best for distributed deployments with multiple server instances.
Redis Store Benchmark (Node.js 20, Redis 7.2 local)
12,000+ ops/sec
0.08ms avg latency
0.35ms p99 latency
Note: Network latency adds ~1-5ms for remote Redis
Bun SQLite (bun:sqlite)
Bun's native SQLite is significantly faster than Node.js's better-sqlite3.
bun:sqlite Store Benchmark (Bun 1.0.20)
95,000+ ops/sec
0.01ms avg latency
0.05ms p99 latency
HTTP Overhead
How much does hitlimit slow down your API?
| Framework | Without Limiter | With hitlimit (Memory) | Overhead |
|---|---|---|---|
| Express | 45,000 req/s | 42,000 req/s | 7% |
| Fastify | 65,000 req/s | 61,000 req/s | 6% |
| Bun.serve | 120,000 req/s | 105,000 req/s | 12% |
| Elysia | 130,000 req/s | 115,000 req/s | 11% |
Comparison with Alternatives
| Library | Memory (ops/s) | Redis (ops/s) | Bundle Size |
|---|---|---|---|
| hitlimit | 400,000 | 12,000 | ~5KB |
| express-rate-limit | 180,000 | 8,000 | ~15KB |
| rate-limiter-flexible | 250,000 | 10,000 | ~45KB |
| @nestjs/throttler | 150,000 | N/A | ~20KB |
Run Benchmarks Yourself
Terminal
# Clone the repo
git clone https://github.com/JointOps/hitlimit-monorepo
cd hitlimit-monorepo
# Install dependencies
pnpm install
# Build packages first
pnpm build
# Run all benchmarks
pnpm benchmark
# Run specific benchmark
pnpm benchmark:memory
pnpm benchmark:sqlite
pnpm benchmark:redis
# Run Bun benchmarks
pnpm benchmark:bun Results are saved to benchmarks/results/latest.json after each run.