Database / Azure Cosmos DB interview questions
What is Cosmos DB Integrated Cache and how does it reduce RU consumption?
The Cosmos DB Integrated Cache is a server-side in-memory cache built into the dedicated gateway tier. When enabled, it caches the results of point reads and queries at the gateway layer so that repeated identical requests can be served from memory without going to the backend storage partitions — meaning those cached responses consume 0 RU/s.
This is fundamentally different from a client-side cache (like Redis). Client caches are application-managed: you maintain cache keys, TTLs, and invalidation logic in your code, and every new application instance starts with a cold cache. The Integrated Cache is managed by Cosmos DB itself, is shared across all clients connecting through the same gateway, and is warm for the first client that populates it.
How it works:
- A client sends a read request through the dedicated gateway.
- The gateway checks its in-memory cache for a matching item or query result.
- On a cache hit, the response is returned immediately — 0 RU consumed.
- On a cache miss, the backend is queried normally, the result is cached, and RU is charged as usual.
Cache invalidation is automatic: when an item is written or modified, its cached entry is invalidated. The cache respects the consistency level — if you use Session or Eventual consistency, the gateway may serve slightly stale responses (by design for those levels), which improves hit rates. Strong consistency is not compatible with the Integrated Cache.
The Integrated Cache requires using the dedicated gateway tier (not the direct connectivity mode) and is best suited for read-heavy workloads where the same data is requested repeatedly — leaderboards, product catalogs, configuration data, or user profiles with hot-spot access patterns.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
