Benchmark
Hiệu suất In-Memory
Thao tác cache trực tiếp (không có network overhead):
╔══════════════════════════════════════════════════════╗
║ Cache Operations (5000 ops, 1000 keys) ║
╠══════════════════════════════════════════════════════╣
║ GET: 120,000+ ops/sec avg: 0.008ms ║
║ SET: 131,000+ ops/sec avg: 0.008ms ║
║ MIXED: 119,000+ ops/sec (80% read, 20% write) ║
╚══════════════════════════════════════════════════════╝Phân phối dữ liệu
╔══════════════════════════════════════════════════════╗
║ 1000 keys trên 3 nodes ║
║ node-0: 365 keys (36.5%) ██████████████████████ ║
║ node-1: 346 keys (34.6%) █████████████████████ ║
║ node-2: 289 keys (28.9%) ████████████████████ ║
╚══════════════════════════════════════════════════════╝Thực tế: Tích hợp Medusa.js
Benchmark với Medusa server đang chạy và PostgreSQL:
| Test | Throughput | Avg | P50 | P95 | P99 |
|---|---|---|---|---|---|
| GET /products (100 items) | 22 req/sec | 45ms | 44ms | 52ms | 97ms |
| GET /products?limit=10 | 30 req/sec | 34ms | 33ms | 42ms | 56ms |
| 10 concurrent requests | 6 req/sec | 171ms | 170ms | 206ms | 239ms |
Kết quả chính: Cache reads nhanh hơn PostgreSQL queries 5600 lần.
Cách chạy
bash
# Benchmark in-memory
npm run benchmark
# Test sử dụng bộ nhớ
npm run memory
# Benchmark tích hợp Medusa
cd medusa && node scripts/benchmark-real.js