By Dan Spangenberger on Jun 17, 2013 8:00:00 PM
One of the best things about Rails is how easy it is to interact with the database. Unfortunately, that's also one of the worst things about Rails if you care about performance (which you hopefully do). Inevitably, you'll find your application slowing down and track down the root cause to a recent change that spawned far more database queries than you expected, or hits the database when you least expected it.
Salsify is a single-page app (Backbone on the client, Rails + Postgres + Elastic Search on the backend) that requires very low latency responses to provide an interactive experience for browsing and editing product catalogs. In order to satisfy these latency requirements we rely heavily on Delayed Job for running time consuming tasks like importing data, exporting data, and applying bulk updates in background processes. We've found useful pattern for using Delayed Jobs callbacks and hooks together that I wanted to share.