retrystorm · Learn · Interview practice · Glossary · Components

Home › Interview practice › Right-Size the Cache

Right-Size the Cache

A big catalog behind a slow database. Find the cache that makes pages fast for the least money.

Inkwell Shop's catalog has grown to 50 000 products. They're served by the shop's catalog database, which is slow: about 25 ms a read. A few thousand products get most of the views.

Product pages have to be fast for most shoppers, and finance wants the shop to cost as little as possible to run.

What it does

  • Read: a shopper opens a product page.
  • Write: a writer updates a product.

Workload

A steady 8 000 rps, 98% reads / 2% writes, for 20 seconds, against 50 000 products.

How to build it

  1. Build client, load balancer, app server, cache, database. The app servers are fixed.
  2. Try a few cache sizes. Watch the hit rate in the cache's metrics, and the cost in the results header.
  3. Does a bigger database do the job of a cache? Which costs less?

Part of Chapter 14: Sizing a Cache.

About · Contact · Privacy · Terms of use