About a year ago, I was tasked with solving a hard problem (a tricky resource reservation problem with arbitrary quantities and spans). As with all problems, there were constraints: in this case use Ruby, use MySQL, make it respond in under 100ms, handle spikey traffic. This was a computationally intensive service for which no regular caching was possible so the only plausible solution (after eliminating many options) was adding a partially precomputed table to the database which could shortcut some of the calculation (ok, so it’s like a cache, but it’s an incomplete one).
In this way, Ruby could amortize out the calculation (a little bit on update, a bit little bit on read) and then also employ some pretty crazy SQL to help speed it all along.
Special Note: It may sound like an easy problem, but after you work on all the cases you have to deal with, you’ll realize it is in fact a hard problem for Ruby to solve with the given constraints.