EVCache: The Cache Layer That Makes Microservices Affordable

Why / The Problem

One request can fan out to hundreds of services (see Strangler fig migration), and the Hystrix part’s breakers assume each call returns or fails fast. Cassandra — Netflix's primary durable store — scales and survives, but isn't sub-millisecond on every read. If every downstream call hit it, a homepage load would blow its latency budget, before even counting the raw read load of hundreds of millions of members.

request latency ≈ Σ (calls on the critical path) × per-call latency

A 1 ms cache hit and a 10 ms database read are not "both fast." Across a deep fan-out they are the difference between a page that renders and one that times out.

How It Works

EVCache ("Ephemeral Volatile Cache") is memcached plus a Netflix-authored client that handles everything memcached doesn't: replication, topology awareness, consistent hashing, dead-node handling. The decision that matters most is the read/write asymmetry.

Reads never leave the availability zone; writes go to every zone. Three zone panels sit side by side: AZ-a, AZ-b and AZ-c. Each holds an identical green box reading every key lives here, on this zone's own servers — every zone is a full copy of the keyspace, not a slice of it. Inside the AZ-a panel is the service instance, and nested inside that process is the EVCache client library, which picks the server for a key, skips dead ones, and does the fan-out itself. The read is a single short thick green arrow from the client straight down to AZ-a's own cache: GET, local AZ only, about 0.4 milliseconds, one hop, no boundary crossed — it stays inside the AZ-a panel. The write is a blue bus that leaves the AZ-a panel and drops into all three caches, so two of its three arrows cross a zone boundary; it costs about a millisecond, three times the RAM and three times the write traffic, and the client waits for all three. Only a cache miss leaves the cache tier: a dashed purple arrow from AZ-a's cache to Cassandra, the regional durable store, at about 5 to 10 milliseconds. A dashed red box marks the hop that never happens: a cross-AZ read would cost about 1 millisecond instead of 0.4 and, on AWS, a separate per-gigabyte inter-zone bill, and it is never needed because the local ring is already a complete copy. Finally, there is no server-side replication at all: memcached servers never talk to each other, with no gossip and no awareness that the other zones exist — all of the replication logic lives in the client library.
Reads never leave the AZ; writes go to every AZ. Each availability zone holds a complete copy of the keyspace — which keeps reads strictly local and makes losing a zone a performance event, not a cache-locality collapse.

Reads: local, always

An instance in AZ-a reads only from AZ-a's servers — a sub-millisecond local hop instead of a slower, separately billed cross-AZ trip. That only works if every zone holds everything, which is what the write path pays for.

Writes: everywhere, on purpose

A SET fans out to all three zones, so each holds the entire keyspace. The usual alternative — one copy sharded across the region — uses a third of the memory but, when AZ-a dies, loses a third of the keys, so healthy instances in surviving zones start missing too.

With full replication AZ-b's hit rate is unchanged, and traffic rerouted from AZ-a lands on already-warm keys. Losing a zone costs capacity, not locality — what Chaos Gorilla (see Chaos engineering) verifies. The price, 3× RAM and 3× write fan-out, is affordable only because nothing here is a source of truth.

  1. The client absorbs node failure — one server, not the zone. A zone is ~20 memcached servers on a consistent-hash ring, each owning one arc of the keyspace (its "slice," ~1/20th of the zone's keys). When one server dies, the client drops it from the ring; only that server's slice misses. The other ~19 servers, and the ~19/20ths of keys they own, are untouched. Callers see a degraded cache (a fraction of keys falling back to the source of truth), never total failure — a slightly higher Cassandra read rate, not a stampede.
  2. Look-aside in front of Cassandra for most hot-path reads: check EVCache, fall through to Cassandra on a miss, populate EVCache for next time. Cassandra is durability and correctness; EVCache is what actually answers the request, almost always.
  3. Explicitly ephemeral and volatile. The name is a contract: nothing in EVCache is a source of truth, and every entry is reconstructible from Cassandra. So losing a node — or a whole AZ — is a performance event, not data loss, and the tier is freely disposable during chaos experiments.

Remove EVCache and the same architecture is too slow to serve a request in budget. The Strangler fig migration part’s decomposition and the Hystrix part’s containment are necessary but not sufficient — this part is what makes the whole shape of the architecture fast enough to be worth doing at all.

Side read: the two layers of replication — in-region fan-out vs cross-region pipeline

"Writes go everywhere" is really two mechanisms with very different guarantees. Conflating them is the most common misreading of EVCache.

Layer 1 — within a region: client-side fan-out, synchronous

There is no server-side replication: memcached has no gossip and no idea other replicas exist. All topology lives in the EVCache client library inside the calling app instance.

Each AZ is a full replicaEach zone has its own servers and its own key→server mapping, so key K sits on three servers — one per zone.
The client does the fan-outA write finds K's server in every zone and sets them in parallel; a read finds one — in its own zone.
Membership from discoveryThe client learns servers from service discovery; a dead one is dropped and only its keys miss.

"Write everywhere" is one client fanning out N sets, not a cluster replicating among itself — which is why a read never needs to cross an AZ.

The cost: a partial write failure leaves one AZ with a stale value — survivable only because every entry has a TTL and Cassandra remains the source of truth.

Layer 2 — across regions: an asynchronous replication pipeline

Cross-region writes are deliberately off the request path: a 60–150 ms round trip per write would wreck write latency and couple every write to a remote region's health — the coupling the Hystrix part exists to eliminate. The write returns locally; replication follows.

Synchronous inside a region, asynchronous between them. Two AWS region panels stand side by side, separated by a dashed strip marked region boundary. Thick solid arrows mean the caller is blocked on them; thin dashed arrows mean fired and forgotten, nobody waits. Region A is itself split by a dashed rail labelled not on the member's request path. Left of that rail is the synchronous part: the app instance writes K equals v, a thick arrow marked SYNC, the caller waits, about 1 millisecond then done, reaches the EVCache client, and a second thick arrow fans out in parallel to all AZs in region A, each one a full copy, with the client waiting for all of them. The write is finished at that point; everything right of the rail happens after it. Right of the rail is the asynchronous part, still inside region A: a dashed arrow carries key, op and TTL to Kafka, a durable log partitioned by key, so order holds per key and only per key; a second dashed arrow reaches the replication relay, which for a SET does a local GET in region A to fetch the value — so Kafka carries keys, not payloads, and notes for keys already overwritten just drop. One dashed arrow leaves the relay and crosses the region boundary over best-effort HTTPS, 60 to 150 milliseconds, and nobody waits for it. Inside region B the regime is synchronous again: thick arrows run from the replication proxy to a region B EVCache client and then fan out in parallel to all AZs in region B, each one a full copy. The relay has two choices of what to ship: A, the value, which keeps region B warm without ever touching its own Cassandra, at a real cross-region bandwidth cost; or B, only the delete, which is far cheaper and leaves the remote cache colder, and can also outrun Cassandra's own cross-region replication. The last hop is best-effort: the HTTPS send to region B can fail outright, and that write is then simply never replicated — survivable only because every entry carries a TTL and Cassandra remains the source of truth.
Synchronous inside a region, asynchronous between them. The write returns locally and replication happens behind it — best-effort, never on the request path.

Why the Kafka message carries the key and not the value

Easy to read past, hard to re-derive. One write in region A:

1. app writes K=v  →  EVCache client fans out to every AZ in region A
                          SYNC — the caller waits here, ~1 ms, then the write is done
2. app drops a note on Kafka: {key: K, op: SET, ttl: 300}
                          ASYNC — fire and forget
   ─────────── the member's request has already returned by this point ───────────
3. relay reads the note off Kafka
4. relay does a LOCAL GET on K against region A's own EVCache   →   gets the value
5. relay ships {K, value} over HTTPS to region B's replication proxy
6. proxy hands it to a region B EVCache client, which fans out to B's AZs

Step 4 carries the weight. The app had the value at step 2 and could have put it in the message. It doesn't, for three reasons:

  1. Otherwise Kafka becomes a durable copy of an ephemeral tier. Kafka persists and replicates every message; carrying values would durably store, several times over, data defined as volatile and reconstructible — exactly what this part says the cache must never be. Keys are tens of bytes, values kilobytes: same message rate, a fraction of the cost.
  2. Re-reading at send time collapses lag. K is written 50 times in a second; the relay is 3 s behind with 50 notes queued. Every note's local GET returns v50, so all 50 ship the newest value. Carrying payloads would ship v1, v2, v3… — region B serving already-dead values through the catch-up window, and any reordering pinning an old value over a newer one.
  3. Obsolete work deletes itself. If K was evicted, deleted or expired before the relay reached its note, the GET misses and the message is dropped — no send, no bandwidth, no cleanup or compaction logic. It also keeps Kafka payloads small.

Variant A — replicate the value

The relay ships the value. Region B's cache stays warm and correct without touching its own Cassandra — at the cost of cross-region bandwidth on every mutation.

Variant B — replicate only an invalidation

Ship only the key delete; region B refills from its own Cassandra replica (which replicates cross-region independently). Far cheaper on bandwidth, but a colder remote cache.

Three further consequences of Layer 2 being asynchronous:

  1. Ordering is per-key only. Kafka is partitioned by key, so each key's notes stay in order; nothing is ordered across keys. Any invariant spanning two entries can be seen torn in a remote region.
  2. No cross-region read-your-writes. Invisible normally, since members are sticky-routed to one region (see Regional failover) — until a region evacuation steers a member into a region whose cache is cold and fed by a possibly lagging pipeline.
  3. Best-effort by design. The HTTPS hop to region B can fail and that write is never replicated; relay outages or Kafka lag mean staler, colder remote caches — never data loss, because every entry is reconstructible from Cassandra.

The Invariants

  • Guarantees: Keys resident in the local AZ are served in sub-millisecond time without touching Cassandra — the property the whole fan-out's latency budget depends on.
  • Does not guarantee: Low Cassandra load in all conditions: a cold cache (new deploy, wide invalidation, an AZ event) sends a real surge to the durable store — which is why chaos experiments on this path matter. Nor cross-region freshness: the async, best-effort pipeline lets a remote region serve a stale entry until its TTL expires.