Back to News

Clearing Our Caching Issues

31 October, 2017

Caching. At times it’s a blessing and a curse for web developers and server caching in particular, was causing us quite a few headaches recently. As with all caching, memory usage builds over time and in certain circumstances that memory either runs out or overloads.

Our Problem

We’re .NET developers and primarily, we work using the Kentico CMS. One of the problems we kept running into was high memory usage due to a reliance on caching, and over time this was leading to high memory usage.

One of our issues was outlined when performing new code deployments, which cause the application pool to refresh and results in the server cache being cleared, which would slow down performance for a period of time due to the database calls that would then be needed (and subsequently cached) on the first load.

Our Solution

Our solution for this problem came from Amazon Web Services (AWS), in particular a solution called Redis. Redis is an ‘elasti-cache’ service. An elastic-cache service, like elastic, stretches and contracts depending on the caching requirements, so when memory usage is increasing it can stretch to accommodate more.

To get this up and running we simply created an instance of Redis and connected our services into it. Now our cache items are stored in Redis and not the web server(s) running the website. The Redis Desktop Manager Tool gives us huge amounts of flexibility and customisation so we can ensure the solution if fit for purpose. We can also store objects of any type in the cache; Boolean, integers, lists, pages and so on.

The Benefits

With this Redis implementation in place caching no longer hogs machine memory and it bypasses our issue of needing to rebuild the cache after development changes cause it to be cleared. Moreover, Redis allows us to effectively manage and expire individual cache keys giving us more granular control over caching. Security is improved too as the solution can only be connected to from the same network source that connects to our other Amazon instances.

So thanks to Redis, caching is now more of a blessing and less of a curse.