DEV Community

Cover image for Monitor Solid Cache in Rails with AppSignal
Connor for AppSignal

Posted on • Originally published at blog.appsignal.com

Monitor Solid Cache in Rails with AppSignal

AppSignal now supports Solid Cache, giving you the same deep cache performance insights you'd get from other Rails cache stores.

In this blog post, we'll give you a quick tour of Solid Cache, and how you can benefit from monitoring your app's cache with AppSignal.

What is Solid Cache?

Plug and play, database agnostic remote disk storage cache, meaning unlike Redis or Memcached, which are memory stored, Solid Cache uses a SQL database through Active Record, keeping your cache on disk.

Local Remote
Memory
  • MemoryStore
  • RedisCacheStore
  • MemCachedStore
Disk
  • FileStore
  • SolidCacheEntries Table

Solid Cache might be a favorable caching method if you work with an application with a large quantity of relatively stable historical data, like Hey, 37Signal's email service, as besides new mail, previous emails aren't going to change suddenly.

Monitoring Solid Cache with AppSignal

AppSignal was born in the Netherlands, a country known for its windmills, canals, stroopwaffles, and of course, rain. So much rain. Knowing when it's going to rain is very important when a bike is your primary mode of transport, so we've created a Rails app called SkySignal.

SkySignal connects to APIs to consume weather data from across the Netherlands, letting people know if it will rain in their location and helping developers stay dry while being DRY 🥁.

Like Hey, we want to optimize our application's response times by using caching to serve the weather forecast to our users quickly. We will use Solid Cache to cache historic weather data in this case.

We're opting for Solid Cache here for the same reasons Hey did; it allows us to cache large amounts of data for a fraction of the cost of using an alternative cache, like Redis.

Installing Solid Cache

Installing Solid Cache is easy, we'll follow the steps outlined in Solid Cache's Readme:

  1. First, we need to configure Solid Cache as our cache store in our desired env config files:
config.cache_store = :solid_cache_store
Enter fullscreen mode Exit fullscreen mode
  1. Then we need to add solid_cache to our gemfile.
  2. Then we need to create, and run Solid Cache migrations to create our database cache:
rails solid_cache:install:migrations
rails db:migrate
Enter fullscreen mode Exit fullscreen mode

In this case, we want to write our cache to our primary database, but if you want, you can also configure Solid Cache to shard your cache into different data stores. Sharding breaks down your cache into smaller parts and distributes them across different databases (shards).

Next, we want to install AppSignal to monitor our app.

Installing AppSignal

Installing AppSignal is simple; we've created an installation wizard to get you up and monitoring.

To start the wizard, you can click the "Add app" button on the AppSignal Applications overview page, or if you are signed in, you can use this link to start the wizard.

The wizard will let you know once AppSignal has successfully installed, and in the rare event things go wrong, hand you over to our support for some dev-to-dev assistance.

Wizard installation screen

If you want to install AppSignal manually, follow our Installation Documentation.

Now we've installed AppSignal; we can begin monitoring the SkySignal app's performance.

Monitoring Solid Cache

AppSignal collects your application's performance metrics and translates them into actionable insights. AppSignal has a large toolkit of developer-friendly monitoring tools, but for this blog post, we'll focus on the following:

  • Metric dashboards: Visually track your app's performance data, like error rates and global response times. For SkySignal, we'll look at our cache size and performance times.
  • Anomaly detection: Create triggers to alert you when a metric exceeds a specific threshold, for example, when our cache size increases significantly within a short time frame.

Oh, and don't worry if you don't use Solid Cache; no matter your Rails cache store, you'll get the same great metrics in AppSignal!

Monitoring Solid Cache with Dashboards

AppSignal's graphs are a great way of visually monitoring your application's performance. You can add markers to share context about performance spikes and click anywhere on the graph to see a snapshot of your application's performance at that exact moment in time, making debugging a breeze.

Monitoring Response Times

Let's look at our app's performance now that we've configured Solid Cache:

Response time graph

In the graph above, we can see SkySignal has relatively fast response times, and we can also see response time spikes caused by SkySignal consuming batches of new weather data.

Monitoring Cache Size

We've opted to use caching as a stable, efficient way of enhancing our response times by storing large amounts of data in our remote disk cache.

Cache size graph

To ensure our cache is optimal, we can track our cache size, see if it's spiking quickly, and use this data to fine-tune our cache configuration to ensure it's optimal for our application's needs.

See this blog post for more information on setting up a dashboard tracking your Solid Cache table size.

Detecting Cache Anomalies with AppSignal

While AppSignal's dashboards are an elegant and intuitive way to keep tabs on our application's performance. Sadly, we can't spend all day looking at AppSignal's beautiful graphs; this is where Anomaly Detection comes in.

AppSignal's Anomaly Detection allows you to create triggers that notify you to let you know if a specific metric threshold has been met, for example, the error rate has gone above 10%, or your cache storage is being used up too quickly.

Creating a trigger

Anomaly detection allows you to get on with your job. You can configure AppSignal to notify you via email or popular third-party collaboration platforms like Slack and Discord, giving you the peace of mind that you'll be alerted if a trigger is triggered, and monitor your application proactively, preventing bottlenecks before they impact the performance and scalability of your application.

Ready to Start Monitoring Your App's Cache?

At AppSignal, we strive to be awesome at everything we do; that's why we work hard to ensure we support all the latest Rails features and functionality.

When we ask our customers why they find AppSignal awesome, they tell us they like our:

  • An intuitively easy-to-navigate interface.
  • Simple and predictable pricing.
  • Developer-to-developer support.

If you're not already an AppSignal customer click here to create a new trial account. If you're a new trial user, reach out to us once you begin pushing monitoring data, and we'll send a package of Stroopwaffles to you 🍪!

Want to learn more about Solid Cache? We recommend watching Donal McBreen's Rails World talk on YouTube.

Top comments (0)