Skip to content

Performance ​

Measured through real gRPC and serialization, with the server in a JVM of its own on JDK 25 with compact object headers, against a Redis 7.4 container. Load generator and server shared one 10-core laptop, over loopback, so there was no real network unless one was emulated, and the generator competed with the server for CPU. Treat these as an indication, and measure on your own hardware.

Results ​

TargetResultVerdict
50,000 instances and 10,000 Configs in a namespaceWritten in 7 seconds at 64 concurrent writers. A second replica loaded them and was ready in 2 to 3.5 seconds.Met
About 1 KB per instance86 MB for 60,000 objects, about 1.5 KB each, with the index by service and the event windowSlightly over
Write p99 under 20 ms2 ms at about 12,000 writes per second with 16 writers; 8 ms at most. Over an emulated network with Redis and clients each 6 ms away, 15 ms with one writer.Met, but not where 1% of packets are lost
20,000 connections and 100,000 watches on a replicaAll succeeded, in 7 seconds, and the heap grew by about 370 MB.Met
Propagation p99 under 500 msWith every write going to every connection: 89 ms to 5,000 connections, 135 ms to 10,000, and 154 to 189 ms to 20,000 in 4 runs, 400 ms at most. Over an emulated network, 348 ms to 5,000 clients 58 ms away that lose 0.5% of packets.Met
choose() and reading a Config allocate nothingchoose() 24 to 58 million operations per second, reading a Config about 1,500 million, at about 0 bytes eachMet

Propagation is measured in the worst case: every connection watches the same service, and the generator receives every copy on the same machine. In real traffic, an event goes only to those who depend on that service.

Earlier runs at 20,000 connections sometimes had a tail of 1 to 10 seconds. It came from the generator: its gRPC client ran callbacks on a thread for each busy stream, and some 900 threads competed with the server for the 10 cores, while the server had no GC pause and Redis no slow command. With the callbacks on the transport's threads, the tail went away.

The connection figures come from a Linux container on the same laptop, because on macOS a client runs out of ports at about 16,000 connections. That is what stopped earlier runs at about 15,000. The load generator and the server still share 10 cores.

The event window ​

A replica was killed under load, and 100 clients reconnected to another one, all watching one service. Falling out of the window means reading a fresh snapshot of that service, which costs little.

Writes per secondWindowClientsDeliveries per secondgone
About 16010,000100About 16,0000
About 1,60010,0005 / 20About 8,000 / 32,0000
About 1,60010,000100About 160,00097 to 100
About 1,50050,000100About 150,0000

So gone appears only when delivery cannot keep up, around 160,000 per second. The default stays at 10,000, and cosky_watch_gone_total after a rolling update shows whether yours should be larger.

Large Configs ​

A server with 512 MB of heap, with one 1 MB Config written over and over:

Limit in bytesWritesHeapRedis
NoneStarted failing after about 500Reached 510 MB509 MB, after 484
64 MB, in memory onlyAll 800 succeededSteady at about 120 MB825 MB, after 800
64 MB, in memory and in the logAll 800 succeededSteady at about 120 MB92 MB, after 800

It restarted on that log in 4 seconds, and took 50 more writes. Trimming the log made no visible difference to write speed: in alternating runs, 16 writers reached about 11,400 and 9,600 writes per second, against 11,500 and 10,400 before.

A Redis Cluster failover ​

On a cluster of three masters and three replicas in Docker, with a node timeout of 5 seconds, one server wrote a Config every 100 ms to a namespace while its master was stopped:

The masterThe namespace unavailable, 8.0.0-beta.7
Killed (docker kill)10.5 to 15.8 seconds, in three runs
Frozen (docker pause)15.6 seconds

That is the node timeout, the replica's election, and then up to 10 seconds: the server reads the topology every 5 seconds, and each read waits up to 5 seconds for the stopped node. How much of those 10 seconds a run takes depends on when the reads fall: of three kills, two were over after 10.5 and 10.6 seconds, one after 15.8. Meanwhile each request on that namespace failed with STORE_UNAVAILABLE after 5 seconds. 8.0.0-alpha.5 left it unavailable for 53 seconds after a kill, and after a freeze until the master answered again, as it never read the topology again.

A Redis Sentinel failover ​

On a master with one replica and three Sentinels in Docker, which take a master that does not answer for 5 seconds as down, one server wrote a Config every 100 ms while the master was stopped:

The master8.0.0-beta.18.0.0-beta.28.0.0-beta.7
Killed (docker kill)10.2 seconds15.5 seconds15.5 seconds
Frozen (docker pause)Until it answered again: not within 240 seconds16.2 seconds16.2 seconds
Handed over (SENTINEL FAILOVER)At onceAt onceAt once: no write failed while the Sentinels handed over, 1.1 seconds after

A plain connection asks the Sentinels for the master only when it connects. A master that hangs keeps its connections open, so beta.1 went on sending to it, and each request failed after a minute. The server now follows what the Sentinels announce, and a request fails with STORE_UNAVAILABLE after 5 seconds instead. After a kill, beta.1's first request waited 10.2 seconds and then succeeded, longer than a client waits for a call, 10 seconds; now requests fail after 5 seconds each until the server has followed. A Sentinel that hands the master over closes its clients' connections itself, so both follow at once.

Many namespaces, and a Redis Cluster ​

Three replicas followed many namespaces of 50 Instances each, on Redis 7.4 alone and on a Redis Cluster of three masters and three replicas, all in one container on the same laptop. 16 writers wrote 32,000 Configs through one replica, each to a namespace picked at random, and a client on another replica watched 100 of the namespaces.

1,000 namespaces, one Redis1,000 namespaces, Cluster5,000 namespaces, one Redis5,000 namespaces, Cluster
The second and third replicas ready3.3 and 4.0 s3.4 and 4.1 s4.7 and 6.7 s5.2 and 7.5 s
Redis at rest21,000 commands/s, 11% CPU6,700 commands/s and 4% CPU on each master129,000 commands/s, 30% CPU42,000 commands/s and 11% CPU on each master
Writes8,354/s, p99 5 ms7,809/s, p99 7 ms6,739/s, p99 9 ms6,240/s, p99 9 ms
Redis while writing77% CPU39 to 43% CPU on each master84% CPU48 to 55% CPU on each master
A write reaching the watcher on another replica, p9914 ms23 ms8 ms16 ms

At rest, each replica reads each namespace once a second, should a hint have been lost: about seven Redis commands a read. That load grows with the namespaces times the replicas, and not with clients. On one Redis it reached 30% of its CPU at 5,000 namespaces and three replicas; a Cluster spreads it over its masters, and a longer cosky.store.redis.tail-poll-interval lowers it, at the cost of a slower recovery from a lost hint.

A write cost about 35 Redis commands with three replicas: the write itself, and one read of the namespace by each replica. In a Cluster, the hint that a write publishes reaches every node, which showed as 4,000 to 5,000 messages a second received by each master, at no visible cost. Here the laptop, not Redis, limited the writes: one Redis was close to saturated, while the masters of the Cluster had half their CPU left.

The targets above, measured again on a Cluster, matched one Redis: one namespace of 50,000 Instances and 10,000 Configs, 17,500 writes per second with 16 writers at p99 2 ms, 5,000 connections watching, propagation p99 103 ms, and a second replica ready in 2.9 seconds.

Over an emulated network ​

The targets above, measured again with a network between the server and Redis, and between the clients and the server: 5,000 connections watching, one namespace of 50,000 Instances and 10,000 Configs. Each link is a Toxiproxy relay in a container, whose interface netem shapes, so that each direction is delayed once. The round trips are measured one request at a time, as netem here delays a packet alone on the link by milliseconds more than it is told (how it was run).

LoopbackRedis and clients 6 ms awayThe same, 0.1% of packets lost7 ms with jitter, 1% lostClients 58 ms away, 0.5% lost
netem, each directionnone0.1 ms0.1 ms, 0.1% loss1 ± 0.5 ms, 1% lossRedis 0.1 ms; clients 25 ± 5 ms, 0.5% loss
Round trip to Redis, p500.3 ms5.9 ms5.9 ms7.1 ms5.8 ms
Round trip to the server, p500.4 ms5.7 ms5.9 ms6.1 ms57.8 ms
Writes, one writer, p50 and p99under 1 ms9 and 15 ms9 and 15 ms15 and 232 ms62 and 294 ms
Writes, 16 writers17,422/s, p99 2 ms4,973/s, p99 9 ms4,454/s, p99 11 ms1,177/s, p99 24 ms253/s, p99 96 ms
Propagation to 5,000 connections, p50 and p9957 and 120 ms76 and 127 ms79 and 254 ms91 and 361 ms110 and 348 ms
A second replica ready3.4 s3.6 s3.4 s6.4 s3.5 s

Through the relays with no delay, the results matched loopback: propagation p99 115 ms against 120 ms.

One data center is 0.1 to 0.5 ms across, between loopback and these 6 ms. One writer, whose writes cross the links alone, met the 20 ms target: p99 15 ms. Propagation p99 was 127 ms, against 120 ms on loopback. 16 writers write less often the farther away they are, as each waits for its answer: that is the load generator, not the server.

Loss costs more than distance. TCP often resends a lost packet only after a timeout, at least 200 ms on Linux. A packet lost on a write's way, from the writer through the server to Redis and back, holds up that write's event for every connection. Of 100 writes measured, one such write sets the p99, and 0.1% loss doubled it, to 254 ms. With 1% lost on every link, one writer's p99 was 232 ms: a write crosses a link four times, in packets of its own, so more than 1% of writes lose one and wait for its resending. Propagation p99 stayed under 500 ms on every network here; the slowest event took 779 ms, with 1% lost.

Over the link to those clients, loading the namespace took 60 seconds instead of 6, and opening the watches 224 seconds instead of 14: the load generator writes 64 at a time and waits 58 ms for each, and all the snapshots of 5,000 clients crossed one relay and one netem queue, where real clients would each have a path of their own.

Leases ​

100 clients, each with an Instance on its lease (a TTL of 30 seconds, renewed every 10), over a link, for 300 seconds, while a client on loopback watched their Instances:

The clients' linkRegistered inFewest Instances seenLeases expired
25 ± 5 ms each way, 0.5% lost: a round trip of 58 ms4.0 s100 of 1000
100 ± 20 ms each way, 5% lost: a round trip of about 200 ms17.5 s100 of 1003

On the second link, a call could wait for several resendings, which is why registering took 17.5 seconds. The three leases that expired held no Instance: the watcher saw all 100 throughout, looking every 100 ms, while an Instance whose lease runs out stays gone until its client finds out at its next renewal, up to 10 seconds later, and registers it again. They fit leases granted to calls whose answer never reached the client, which then asked again: it kept the lease it was given, and the server let the other run out.

How it was run ​

The load generator and the server ran in a Linux container on the laptop's Docker VM (OrbStack), on the network of the VM itself, beside Redis and the relays in containers of their own, so that only the VM's kernel stood between them. Through the VM's port forwarding to macOS, packets were lost even without netem, and about 5% of the events to 100 connections came 200 ms late, a resending. In this VM, netem delays a packet alone on the link by up to a few milliseconds more than told, as the timer that releases it fires late, while under steady traffic packets leave closer to on time: that is why 0.1 ms became a round trip of 6 ms for one request, and why 16 writers saw shorter writes than one. Its jitter also reorders packets, which a real path seldom does. And the same 10 cores ran the server, Redis, the relays and the load generator.

Not measured ​

  • A real network, or a real data center: the network above was emulated, on one laptop.
  • More than one server replica under connection load.
  • A Cluster of more than three masters, or more than three replicas.
  • Long runs: memory over days, and leaks.

Reproducing ​

bash
COSKY_MEASURE=load COSKY_MEASURE_HEAP=4g ./gradlew :server:test --tests '*LoadMeasurement*'

COSKY_LOAD_CONNECTIONS, COSKY_LOAD_WATCHES_PER_CONNECTION, COSKY_LOAD_PROPAGATION_PAUSE_MS, COSKY_LOAD_RATES, COSKY_LOAD_WINDOW and COSKY_LOAD_WINDOW_CLIENTS set the shape. COSKY_LOAD_SERVER_HEAP sizes the server, and COSKY_LOAD_REDIS_URI uses a Redis you started instead of a container of its own. With COSKY_LOAD_REDIS_CLUSTER=true it is a node of a Redis Cluster, whose nodes must announce addresses the run can reach. Many namespaces on several replicas is another test, shaped by COSKY_LOAD_NAMESPACES, COSKY_LOAD_OBJECTS_PER_NAMESPACE, COSKY_LOAD_REPLICAS and COSKY_LOAD_WRITES:

bash
COSKY_MEASURE=load COSKY_MEASURE_HEAP=2g COSKY_LOAD_SERVER_HEAP=2g ./gradlew :server:test --tests '*LoadMeasurement.many namespaces*'

COSKY_LOAD_REDIS_NETEM and COSKY_LOAD_CLIENT_NETEM put a link between the server and Redis, and between the clients and the server, taking the arguments of tc qdisc ... netem. Leases over such a link are another test, shaped by COSKY_LOAD_LEASE_CLIENTS and COSKY_LOAD_LEASE_SECONDS. On a laptop, run them in a Linux container on the Docker host's network, with JDK 21 to build and a Linux JDK 25 for the server, which Gradle finds in org.gradle.java.installations.paths:

bash
docker run --rm --network host -v /var/run/docker.sock:/var/run/docker.sock -v "$PWD":/work -v /path/to/jdk-25:/opt/jdk25 -w /work \
  -e TESTCONTAINERS_HOST_OVERRIDE=localhost -e COSKY_MEASURE=load -e COSKY_MEASURE_HEAP=3g -e COSKY_LOAD_SERVER_HEAP=2g \
  -e COSKY_LOAD_CLIENT_NETEM='delay 25ms 5ms loss 0.5%' eclipse-temurin:21-jdk \
  ./gradlew :server:test --tests '*LoadMeasurement.the targets*' -Porg.gradle.java.installations.paths=/opt/jdk25

The failovers come from the scripts in testing/failover, which start Redis and a server in Docker, on the image of the version in gradle.properties unless given another:

bash
testing/failover/cluster/up.sh && testing/failover/cluster/measure.py 8181 kill && testing/failover/cluster/down.sh
testing/failover/sentinel/up.sh && testing/failover/sentinel/measure.py pause && testing/failover/sentinel/down.sh

The hot paths of the client are JMH benchmarks:

bash
./gradlew :client:jmh

Released under the Apache License 2.0.