14. What do caches touch?
Signing up*
Logging in
Choosing a profile
Picking liked videos
Personalization*
Loading home page*
Scrolling home page*
A/B tests
Video image selection
Searching*
Viewing title details
Playing a title*
Subtitle / language prefs
Rating a title
My List
Video history*
UI strings
Video production*
* multiple caches involved
18. What is EVCache?
Distributed, sharded, replicated key-value store
Tunable in-region and global replication
Based on Memcached
Resilient to failure
Topology aware
Linearly scalable
Seamless deployments
19. Why Optimize for AWS
Instances disappear
Zones fail
Regions become unstable
Network is lossy
Customer requests bounce between regions
Failures happen and we test all the time
20. EVCache Use @ Netflix
Hundreds of terabytes of data
Trillions of ops / day
Tens of billions of items stored
Tens of millions of ops / sec
Millions of replications / sec
Thousands of servers
Hundreds of instances per cluster
Hundreds of microservice clients
Tens of distinct clusters
3 regions
4 engineers
25. Use Case: Lookaside Cache
Application
Client Library
Client Ribbon Client
S S S S
C C C C
Data Flow
26. Use Case: Transient Data Store
Application
Client Library
Client
Application
Client Library
Client
Application
Client Library
Client
Time
27. Use Case: Primary Store
Offline / Nearline
Precomputes for
Recommendations
Online Services
Offline Services
Online Application
Client Library
Client
Data Flow
28. Online Services
Offline Services
Use Case: Versioned Primary Store
Offline Compute
Online Application
Client Library
Client
Data Flow
Archaius
(Dynamic Properties)
Control System
(Valhalla)
29. Use Case: High Volume && High Availability
Compute & Publish
on schedule
Data Flow
Application
Client Library
In-memory Remote Ribbon Client
Optional
S S S S
C C C C
37. Moneta
Moneta: The Goddess of Memory
Juno Moneta: The Protectress of Funds for Juno
● Evolution of the EVCache server
● Cost optimization
● EVCache on SSD
● Ongoing lower EVCache cost per stream
● Takes advantage of global request patterns
38. Old Server
● Stock Memcached and EVCar (sidecar)
● All data stored in RAM in Memcached
● Expensive with global expansion / N+1 architecture
Memcached
EVCar
external
39. Optimization
● Global data means many copies
● Access patterns are heavily region-oriented
● In one region:
○ Hot data is used often
○ Cold data is almost never touched
● Keep hot data in RAM, cold data on SSD
● Size RAM for working set, SSD for overall dataset
40. New Server
● Adds Rend and Mnemonic
● Still looks like Memcached
● Unlocks cost-efficient storage & server-side intelligence
42. Rend
● High-performance Memcached proxy & server
● Written in Go
○ Powerful concurrency primitives
○ Productive and fast
● Manages the L1/L2 relationship
● Tens of thousands of connections
43. Rend
● Modular set of libraries and an example main()
● Manages connections, request orchestration, and
communication
● Low-overhead metrics library
● Multiple orchestrators
● Parallel locking for data integrity
● Efficient connection pool
Server Loop
Request Orchestration
Backend Handlers
M
E
T
R
I
C
S
Connection Management
Protocol
45. Mnemonic
● Manages data storage on SSD
● Uses Rend server libraries
○ Handles Memcached protocol
● Maps Memcached ops to RocksDB ops
Rend Server Core Lib (Go)
Mnemonic Op Handler (Go)
Mnemonic Core (C++)
RocksDB (C++)
46. Why RocksDB?
● Fast at medium to high write load
○ Disk--write load higher than read load (because of Memcached)
● Predictable RAM Usage
memtable
Record A Record B
SST
memtable memtable
SST SST . . .
SST: Static Sorted Table
47. How we use RocksDB
● No Level Compaction
○ Generated too much traffic to SSD
○ High and unpredictable read latencies
● No Block Cache
○ Rely on Local Memcached
● No Compression
48. How we use RocksDB
● FIFO Compaction
○ SST’s ordered by time
○ Oldest SST deleted when full
○ Reads access every SST until record found
49. How we use RocksDB
● Full File Bloom Filters
○ Full Filter reduces unnecessary SSD reads
● Bloom Filters and Indices pinned in memory
○ Minimize SSD access per request
50. How we use RocksDB
● Records sharded across multiple RocksDB per node
○ Reduces number of files checked to decrease latency
R
...
Mnemonic Core
Key: ABC
Key: XYZ
R R R
51. Region-Locality Optimizations
● Replication and Batch updates only RocksDB*
○ Keeps Region-Local and “hot” data in memory
○ Separate Network Port for “off-line” requests
○ Memcached data “replaced”
52. FIFO Limitations
● FIFO compaction not suitable for all use cases
○ Very frequently updated records may push out valid records
● Expired Records still exist
● Requires Larger Bloom Filters
SST
Record A2
Record B1
Record B2
Record A3
Record A1
Record A2
Record B1
Record B2
Record A3
Record A1
Record B3Record B3
Record C
Record D
Record E
Record F
Record G
Record H
time
SSTSST
62. Challenges/Concerns
● Less Visibility
○ Unclear of Overall Data Size because of duplicates and expired records
○ Restrict Unique Data Set to ½ of Max for Precompute Batch Data
● Lower Max Throughput than Memcached-based Server
○ Higher CPU usage
○ Planning must be better so we can handle unusually high request spikes
63. Current/Future Work
● Investigate Blob Storage feature
○ Less Data read/write from SSD during Level Compaction
○ Lower Latency, Higher Throughput
○ Better View of Total Data Size
● Purging Expired SST’s earlier
○ Useful in “short” TTL use cases
○ May purge 60%+ SST earlier than FIFO Compaction
○ Reduce Worst Case Latency
○ Better Visibility of Overall Data Size
● Inexpensive Deduping for Batch Data
69. Lost Instance Recovery
Cache Warmer
(Spark)
Application
Client Library
Client
S3
Partial Data Flow
Metadata Flow
Control Flow
Control
Zone A Zone B
Data Flow
70. Backup (and Restore)
Cache Warmer
(Spark)
Application
Client Library
Client
Control
S3Data Flow
Control Flow
71. Moneta in Production
● Serving all of our personalization data
● Rend runs with two ports:
○ One for standard users (read heavy or active data management)
○ Another for async and batch users: Replication and Precompute
● Maintains working set in RAM
● Optimized for precomputes
○ Smartly replaces data in L1
external internal
EVCar
Memcached (RAM)
Mnemonic (SSD)
Std
Batch