✏️ Explanatory Question

Your design needs 50 TB of RAM for its cache. How do you respond to that constraint?

👁 9 Views
📘 Detailed Answer
🟢 Easy
No previous question
No next question
💡

Answer with Explanation

An estimate that produces an absurd number is useful information - it means an assumption is wrong. Do not just say "we will buy more servers."

1. Re-examine the working set. 50 TB usually means you assumed the whole dataset must be cached. Access is skewed: if 90% of reads hit the last 24 hours, cache only that and 50 TB may become 500 GB.

2. Reduce what is stored per entry. Cache IDs instead of full objects; store a compact binary encoding rather than JSON, which is often a 3-5x saving; drop fields the read path does not use.

3. Use a probabilistic structure where exactness is not needed. A Bloom filter can answer "is this key definitely absent?" in a few bits per key - perfect for avoiding pointless database lookups. HyperLogLog gives distinct counts in kilobytes instead of gigabytes.

4. Accept a lower hit rate deliberately. Compute the cost: dropping from 95% to 85% doubles database load. Sometimes that is cheaper than the RAM; sometimes it is not. Do the arithmetic out loud.

5. Tier it. Hot in RAM, warm on local SSD (about 100 microseconds, still far better than a network database call), cold in the database.

The meta-point: when a number comes out absurd, question the assumption rather than the budget.

No previous question
No next question