educative.io

Why is cache expiry time 24 hours?

When estimating the memory for cache, it seems we’re assuming a cache expiry time of 24 hours here. How is the cache expiry time determined?

Since we have 20K requests per second, we will be getting 1.7 billion requests per day:
20K * 3600 seconds * 24 hours = ~1.7 billion
To cache 20% of these requests, we will need 170GB of memory.
0.2 * 1.7 billion * 500 bytes = ~170GB

Can’t still figure this out. It can be an hour or a week. They should have considered and explained things like checking more metrics like db load, latency and performance trade offs before coming up with this number. And, the cache memory should be only needed for write requests (20 times less)

Any answers for this one?

No, there will only be a single write per url, so what could we cache on? (we don’t store analytics, so we don’t have hit count)

since the caching is done for most used links (which is a READ), it’s must be done on the read path

1 Like

When estimating the memory for cache, it seems we’re assuming a cache expiry time of 24 hours here.

The estimation is for how much memory you need to be able to cache one day worth of traffic. The eviction policy is LRU, and entries are evicted as soon as memory is filled up, regardless of time.
Since traffic patterns repeat daily usually, it’s a fair bet to do the estimation for 24h.

1 Like