98.4%fewer Redis script calls
500 keys in one tick: 8 Lua scripts, not 500.
Introducing LazyLayers 9.0. Multi-layer caching, intelligent batching and outage recovery.
Explore what’s newLazyLayers Benchmarks · v9.0Updated
Measured on 9.0.0 against a real Redis and a fleet of six servers in Docker. Every number is a row of BENCHMARKS.md with the command that produced it.
9.0.0
98.4%fewer Redis script calls
500 keys in one tick: 8 Lua scripts, not 500.
19×faster pattern delete
invalidateByPattern on 500 keys.
63%shorter worst event-loop stall
256 KiB to 1 MiB values, compressed off the event loop.
20origin loads for 1,200 callers
6 servers, 20 cold keys: one getOrSet load per key.
Redis script calls for 500 keys
Sources: redis-batch.json (2026-12-04, median of 5) and the fleet run.
8.0 against 0.7
The same machine, 0.7.0 rebuilt from its tag, paired runs.
Against other libraries
What does a cached getOrSet cost?
ns per call · lower is better
The fastest read-through hit tested. Reference mode returns the stored object. Encoded mode, the default, decodes a private copy, so callers cannot change the cached value.
10,000 resident keys, 500,000 awaited getOrSet calls in random order.
How often does the cache send you to the database?
loader calls per 300,000 requests · lower is better
S3-FIFO, the default eviction policy, keeps the keys that are read again: 75.9% hits against 72.9%, so 11% fewer calls reach your database.
300,000 getOrSet calls, Zipf α = 1.0 over 100,000 keys, cache holds 10%.
How long until every caller has a value?
ms, loader takes 20 ms · lower is better
Dashed line: 20 ms loader, the least any library can take.
Every library ran the loader once. Lazy Layers is within 5 ms of the fastest, and is the only one that also coordinates the load across servers.
10,000 concurrent getOrSet calls for one cold key, with a 20 ms loader.
Apple M5, 10 logical CPUs · Node 24.21 · 2026-11-12 · fresh process per run, median of 5 · Every number, command and raw file
One cold key
Every caller asks for the same missing key at the same moment. The loader stands in for a 25 ms database query and counts each call. Each caller checks that it got the value from that one load.
How it works. Inside a process, callers for the same key join the load already running. Across servers, a Redis lease lets one of them run the query. The others wait, and the event bus wakes them when the value is published. Setting: inflight.maxWaiters was raised to the callers per process. The default of 10,000 caps memory and rejects the rest with InflightOverloadError. All 10 processes ran on one machine with Redis 7 in Docker. Three repeat runs took 133 to 206 ms across servers and 277 to 295 ms in one process.
One million requests
A user API (GET /users/:id, 1% PUT) on one Node.js process, hit with 1,000,000 requests over 256 keep-alive connections. User ids follow a Zipf curve over 100,000 users. The database is simulated: 10 connections, 2 ms per query. Same run with and without LazyLayers, starting cold.
Where each read was answered
| 1,000,000 requests | LazyLayers 8.0 | No cache |
|---|---|---|
| Requests per second | 47,058 | 4,394 |
| Latency p50 | 2.01 ms | 58.0 ms |
| Latency p99 | 44.7 ms | 66.0 ms |
| Database queries | 98,515 | 1,000,000 |
| Server CPU per request | 16 µs | 50.1 µs |
| Server CPU, average | 75.5% of a core | 22% of a core |
| Peak memory (RSS) | 286.5 MB | 170.2 MB |
| Peak heap | 128.2 MB | 62.6 MB |
| Failed requests | 369 | 0 |
Read this before quoting it. 369 requests (0.04%) failed: each was a read that raced a PUT to the same key, and the lease refused to publish the old value. With writes switched off, 300,000 requests had no failures. It is on the roadmap. The p99 comes from the cold start: the first read of each user waits for the 10-connection pool. The load generator ran on the same machine (Apple M5, Node 24.21, one API server process, Redis 7 in Docker capped at 1 CPU, load generators on the same machine). The database is simulated, so the numbers describe the cache and the server, not your queries.
Per instance
Estimates, not measurements. We take the measured 16 µs of server CPU per request and scale it to common cloud machines.
req/s ≈ vCPUs × (1,000,000 ÷ 16 µs) × core factor × 0.7
One Node.js process per vCPU. Core factor: 0.5 for an Arm vCPU (Graviton, Axion), 0.4 for an x86 vCPU (one hyperthread), each against one Apple M5 core. These are our assumptions. 0.7 keeps 30% CPU in reserve. Burstable machines count their baseline, not their peak. Memory is 290 MB per process, the measured peak with a 64 MB L1.
| Instance | vCPU · RAM | Requests / s | Database queries / s | Memory used |
|---|---|---|---|---|
| AWS EC2t4g.mediumburstable, 20% baseline per vCPU | 2 · 4 GB | ~8,800 | ~860 | 580 MB (14%) |
| AWS EC2t3.mediumburstable, 20% baseline per vCPU | 2 · 4 GB | ~7,000 | ~690 | 580 MB (14%) |
| AWS EC2m7g.large | 2 · 8 GB | ~44,000 | ~4,300 | 580 MB (7%) |
| AWS EC2m7i.large | 2 · 8 GB | ~35,000 | ~3,400 | 580 MB (7%) |
| AWS EC2c7g.xlarge | 4 · 8 GB | ~88,000 | ~8,600 | 1,160 MB (14%) |
| AWS EC2c7i.2xlarge | 8 · 16 GB | ~140,000 | ~14,000 | 2,320 MB (14%) |
| AWS ECS Fargate0.5 vCPU · 1 GB | 0.5 · 1 GB | ~8,800 | ~860 | 290 MB (28%) |
| AWS ECS Fargate1 vCPU · 2 GB | 1 · 2 GB | ~18,000 | ~1,700 | 290 MB (14%) |
| AWS ECS Fargate2 vCPU · 4 GB | 2 · 4 GB | ~35,000 | ~3,400 | 580 MB (14%) |
| Google Cloude2-mediumshared core, 1 vCPU sustained | 2 · 4 GB | ~18,000 | ~1,700 | 580 MB (14%) |
| Google Cloude2-standard-2 | 2 · 8 GB | ~35,000 | ~3,400 | 580 MB (7%) |
| Google Cloudn2-standard-4 | 4 · 16 GB | ~70,000 | ~6,900 | 1,160 MB (7%) |
| Google Cloudc4a-standard-2Axion | 2 · 8 GB | ~44,000 | ~4,300 | 580 MB (7%) |
| Google Cloud Run1 vCPU · 512 MiB | 1 · 512 MiB | ~18,000 | ~1,700 | 290 MB (57%) |
Your handler adds to this. The 16 µs covers a bare node:http handler and the cache. Authentication, logging, a framework and real serialisation all cost CPU, so measure your own route and add it before you size anything. Without a cache, the limit is usually the database rather than the instance: 10 connections at 2 ms is about 5,000 queries a second, whatever the machine. Run node benchmarks/api-stress.mjs on your own instance for a real number.
Stress and failure
Fifteen fault scenarios against a real Redis in Docker: workers frozen and killed mid-refresh, Redis stopped, paused and restarted, Pub/Sub cut, the origin overloaded. LazyLayers 8.0 passed all fifteen on 2026-11-12.
| Fault | What happened | Result |
|---|---|---|
| Loading server killed mid-refresh | SIGKILL on the lease holder. A replacement loaded after the lease expired, 191 ms later. The origin saw one load. | |
| Process frozen past its lease | SIGSTOP beyond the lease TTL. A replacement won, and the resumed process could not overwrite the newer value. | |
| Redis stopped while taking a lease | The fallback kept the winning value and suppressed the stale publication to peers. | |
| Redis paused during a publish | One publication sent, no blind replay, no L1 or peer priming on an unknown outcome. | |
| Redis restarted | Leases taken before the restart were rejected afterwards. | |
| Pub/Sub connection dropped | The missed event was detected, and L1 was trusted again after reconnecting, 71 ms after the fault cleared. | |
| Origin overloaded | 32 requests against 2 active and 4 queued loads: 6 loads ran, 26 were rejected at once, and the queue drained. | |
| 100 cache instances, one cold key | 2, 10, 50 and 100 instances sharing Redis, up to 200 requests: one origin load each time. | |
| Corrupt or oversized records | A corrupt record became a miss. An 8,199-byte record over the size limit became a miss after 29 bytes were read. |
Not measured yet: production traffic, many physical instances under load, rolling deploys, Redis failover and Cluster resharding, packet loss. Recovery times are single observations on one machine (Redis 7 in Docker capped at 96 MiB and 1 CPU, Apple M5, Node 24.21), not latency distributions.
Run them yourself
Clone the repository and run any workload. Results land in benchmarks/results with the machine and Node.js version recorded.
git clone https://github.com/Amon20044/LazyLayers
cd LazyLayers && npm install
REDIS_URL=redis://localhost:6379 node benchmarks/redis-batch.mjs --rounds=5
node fleet/run.mjs // six servers in Docker, under faults
npm run bench:herd // 10,000 callers on one cold key
In our run, one process served 1,000,000 requests at 47,058 per second, using 16 µs of server CPU per request and 75.5% of one Apple M5 core on average. Without a cache, the same API managed 4,394 per second because every request waited for a 10-connection database pool. Your route’s own CPU adds to the 16 µs.
One. 1,000,000 concurrent callers across 10 processes sharing Redis made one loader call, and the other 999,999 received its value within 206.4 ms. Raise inflight.maxWaiters above the default of 10,000 per process for herds that large.
From a cold start, 1,000,000 requests made 98,515 database queries instead of 1,000,000, which is 90% fewer. 73.4% of reads were answered from L1, 10.5% from Redis, 7.1% by joining a load already in flight, and 8.9% by the database.
Two with RedisStore’s v2 key layout, with or without the lock. One script reads the key and takes its lease when it is empty, and one publishes the value and releases the lease. 0.7.0 took seven with the lock.
Peak RSS was 286.5 MB with an L1 capped at 20,000 entries and 64 MB, against 170.2 MB without a cache. Budget about 290 MB per process at that L1 size.