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: 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.
- 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.
- 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.
- 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 replica | Each 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-out | A write finds K's server in every zone and sets them in parallel; a read finds one — in its own zone. |
| Membership from discovery | The 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.
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 AZsStep 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:
- 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.
- Re-reading at send time collapses lag.
Kis 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. - Obsolete work deletes itself. If
Kwas 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:
- 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.
- 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.
- 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.