Within the ideeli application we have a subset of requests which rely on data that is very expensive to generate into a format optimized for the frontend of the site. There are a number of strategies to make this more performant which we will discuss in future posts; for now let’s just assume that we have a json document of sku availability data which takes 30 seconds to compute (from thousands of mysql queries and some processing in the ruby domain).
This data within this json document is time-sensitive (e.g. whether or not the Add-to-cart buttons should show as sold out). So whilst we are happy to cache it for a few minutes, we have to regenerate it on a frequent basis. The typical solution with rails would be to throw an action cache against the particular url, with a 5 minute expiry.
We have a problem with this. When the page expires, all of the requests to the url - for the next 30 seconds that it takes to generate the page …
[Read more]