Introducing LazyLayers 9.0. Multi-layer caching, intelligent batching and outage recovery.

Explore what’s new

LazyLayers Benchmarks · v9.0Updated

Performance you can reproduce.

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

What changed in 9.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

Bulk writes
off500on8
Bulk reads
off500on8
Concurrent reads
off500on8
Bulk deletes
off500on8
Pattern delete
off500on8

Sources: redis-batch.json (2026-12-04, median of 5) and the fleet run.

8.0 against 0.7

What changed in 8.0

The same machine, 0.7.0 rebuilt from its tag, paired runs.

Warm read-through hit, reference mode
180ns
6,490 ns in 0.7
Redis round trips per miss, lock included
2trips
7 in 0.7
Until a waiting server has the value
0.8ms
36 ms in 0.7
Runtime dependency
1dep
8 in 0.7

Against other libraries

Three workloads, six libraries

Read-through warm hit

What does a cached getOrSet cost?

ns per call · lower is better

  1. lazy-layers-cache referenceL1 reference mode 180
  2. layered-loaderLoader with in-memory cache 220
  3. async-cache-dedupememory storage 658
  4. @epic-web/cachifiedlru-cache store 821
  5. bentocache no copymemory driver, serialize: false 1,120
  6. lazy-layers-cache encodedL1 encoded mode (default) 1,504
  7. bentocache defaultmemory driver (default) 2,429
  8. cache-managerwrap, Keyv in-memory store 9,337
  9. cacheablegetOrSet, in-memory primary 9,470

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.

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

1,000,000 callers. One query.

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.

database query for 1,000,000 callers, in both runs
1
callers served the value of that one query
999,999
until all were served, across 10 servers sharing Redis
206ms
until all were served, in one process
294ms

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

1,000,000 requests. One process.

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.

requests per second, against 4,394 without a cache
47,058
fewer database queries: 98,515 instead of 1,000,000
90%
median latency, against 58.0 ms
2.0ms
server CPU per request, 75.5% of one core on average
16µs
1,000,000 requestsLazyLayers 8.0No cache
Requests per second47,0584,394
Latency p502.01 ms58.0 ms
Latency p9944.7 ms66.0 ms
Database queries98,5151,000,000
Server CPU per request16 µs50.1 µs
Server CPU, average75.5% of a core22% of a core
Peak memory (RSS)286.5 MB170.2 MB
Peak heap128.2 MB62.6 MB
Failed requests3690

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

What one instance could carry

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.

InstancevCPU · RAMRequests / sDatabase queries / sMemory used
AWS EC2t4g.mediumburstable, 20% baseline per vCPU2 · 4 GB~8,800~860580 MB (14%)
AWS EC2t3.mediumburstable, 20% baseline per vCPU2 · 4 GB~7,000~690580 MB (14%)
AWS EC2m7g.large2 · 8 GB~44,000~4,300580 MB (7%)
AWS EC2m7i.large2 · 8 GB~35,000~3,400580 MB (7%)
AWS EC2c7g.xlarge4 · 8 GB~88,000~8,6001,160 MB (14%)
AWS EC2c7i.2xlarge8 · 16 GB~140,000~14,0002,320 MB (14%)
AWS ECS Fargate0.5 vCPU · 1 GB0.5 · 1 GB~8,800~860290 MB (28%)
AWS ECS Fargate1 vCPU · 2 GB1 · 2 GB~18,000~1,700290 MB (14%)
AWS ECS Fargate2 vCPU · 4 GB2 · 4 GB~35,000~3,400580 MB (14%)
Google Cloude2-mediumshared core, 1 vCPU sustained2 · 4 GB~18,000~1,700580 MB (14%)
Google Cloude2-standard-22 · 8 GB~35,000~3,400580 MB (7%)
Google Cloudn2-standard-44 · 16 GB~70,000~6,9001,160 MB (7%)
Google Cloudc4a-standard-2Axion2 · 8 GB~44,000~4,300580 MB (7%)
Google Cloud Run1 vCPU · 512 MiB1 · 512 MiB~18,000~1,700290 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

Break things. Watch it recover.

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 scenarios passed, against a real Redis
15/ 15
to recover after the loading server is killed
191ms
cache instances on one cold key, one origin load
100→ 1
to trust L1 again after a Pub/Sub drop
71ms
FaultWhat happenedResult
Loading server killed mid-refreshSIGKILL on the lease holder. A replacement loaded after the lease expired, 191 ms later. The origin saw one load.
Process frozen past its leaseSIGSTOP beyond the lease TTL. A replacement won, and the resumed process could not overwrite the newer value.
Redis stopped while taking a leaseThe fallback kept the winning value and suppressed the stale publication to peers.
Redis paused during a publishOne publication sent, no blind replay, no L1 or peer priming on an unknown outcome.
Redis restartedLeases taken before the restart were rejected afterwards.
Pub/Sub connection droppedThe missed event was detected, and L1 was trusted again after reconnecting, 71 ms after the fault cleared.
Origin overloaded32 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 key2, 10, 50 and 100 instances sharing Redis, up to 200 requests: one origin load each time.
Corrupt or oversized recordsA 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

Same harness, your machine

Clone the repository and run any workload. Results land in benchmarks/results with the machine and Node.js version recorded.

terminal shell
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

FAQ

Questions about the numbers

Read all FAQs

How many requests per second can one Node.js process serve with LazyLayers?

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.

How many database queries do one million callers on one cold key cause?

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.

How many database queries does the cache save under load?

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.

How many Redis round trips does a cache miss cost?

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.

How much memory does LazyLayers use under load?

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.