Call Montréal, Canada 524-949-6869

Blog

Saturday, December 26, 2009

Maintenance and Monitoring Checklist for your Ruby on Rails Application

Before your application goes into production there are some maintenance and monitoring tasks you need to consider. These tasks include:

  1. Backups
  2. Log Rotation
  3. Monitoring
  4. Scheduled Jobs

Backups

You need to maintain offsite backups for your application’s:

  • database,
  • shared assets, and
  • source code repository.

I have a set of backup scripts (executed via a nightly cron process) that dumps the database for each of my applications, which are in turn archived, and then downloaded to my server. Shared assets, those files uploaded via your application typically located in the public folder, are synced to my server and then archived. As my source control is hosted on Github, I don’t need to worry about backing this up.

Log Rotation

Installing the logrotate package will take care of your system logs, but you will need to set up log rotation specifically for your Rails application. I typically deploy my applications using Moonshine, a server provisioning tool from the folks at Rails Machine, so log rotation has been addressed. There maybe some other logs that are generated by your application such as Ferret server. Consider these files in your applications log folder:

  • production.log
  • mongrel.log (not necessary if you deploy on Passenger of course)
  • ferret.log (other log producing components)

Monitoring

Monitoring is split into four categories:

  • Monitoring Services
  • Performance Monitoring
  • External Monitoring
  • Exception Notification

Monitoring services such as Apache, MySQL or even processes that are apart of your application, such as the Ferret server can be monitored by Monit or God. If these services go down unexpected, they are automatically restarted by the monitor.

Performance Monitoring can be broken down further into Server and Application Performance. Munin is a good candidate for the first, while service providers such as New Relic and Scout are good for the later. With Server monitoring you will also want to consider the consumption of resources. For example, how much disk space do I have left? How much RAM do I have left?

An external monitoring service is useful. Services such as Monstatic, 24×7, or Pingdom can notify you when your server is inaccessible.

Finally, the Exception Notification plugin suits my needs to be notified of an exception, but you may prefer a service to manage this such as Airbrake Bug Tracker or Exceptional.

Cron Jobs (Schedule Jobs)

Sometimes you will need to run scheduled jobs against your application such as managing recurring subscriptions. Make sure these are installed and running. It’s best to make these a part of your deployment using whenever or again, my preference is using Moonshine.

If you are you are using ActiveRecord-based sessions in your application, then you will definitely need to setup a task to remove old records in the sessions table.

Developing Ruby on Rails applications and custom Content Management Systems in Montréal. Contact Firsthand.