Interview › Databases & Caching
What is a cache hit ratio, and how do you improve it?
Databases & Caching · Advanced level
Answer
Cache hit ratio is hits divided by total lookups. I improve it by caching the right data, sizing memory, avoiding evictions, using stable keys, warming hot keys, choosing good TTLs, and avoiding unnecessary invalidation.
Technical explanation
Hit ratio equals hits divided by hits plus misses.
A global hit ratio can hide a low-hit critical endpoint, so break down by key prefix or API.
Improving hit ratio requires better key choice, TTLs, memory sizing, warmup, and avoiding unnecessary invalidation.
Hands-on example
Calculation:
keyspace_hits=900000
keyspace_misses=100000
Hit ratio = 900000 / 1000000 = 90%.If evictions are high, add memory, reduce value size, or tune TTL/policy.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Databases & Caching interview questions
- How does ElastiCache provide high availability and automatic failover?
- What is the difference between Redis Sentinel and Redis Cluster?
- What is Redis Cluster, and how does sharding with hash slots work?
- Why are some Redis commands (KEYS, FLUSHALL) dangerous in production?
- What is Redis replication, and how does a replica stay in sync?
- What is the difference between Redis as a cache and Redis as a primary datastore?
- How would you use Redis for rate limiting?
- What is the difference between Redis persistence options RDB and AOF?