Interview Databases & Caching

How would you design caching for a read-heavy microservice?

Databases & Caching · Advanced level

Answer

For a read-heavy microservice, I cache hot, expensive, safe-to-stale data using clear key naming, TTL plus jitter, explicit invalidation, request coalescing, warming, and fallback protection for the database.

Technical explanation

Start from metrics: hot endpoints, expensive queries, result size, and allowed staleness.

Use Redis/Valkey shared cache for common data and local cache for tiny ultra-hot config.

Protect the database from miss storms with coalescing, warmup, and fallback rate limits.

Hands-on example

Read-heavy product cache:

product:v3:{id} TTL 15m+jitter

product-price:v1:{id} TTL 60s plus explicit invalidation

Redis timeout 50ms.

On miss, coalesce requests and rate-limit DB fallback.

Preparing for an interview?

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

← All Databases & Caching questions