Archive for May, 2008
Ignore This
May 21, 2008Rails Scalability 01: Enter MiniMe — MiniMagick to be Specific
May 9, 2008Note: I’m quite certain that I’ve bastardized either capitalization of use of / lack there of of _ between the names of the different open source projects here. My apologies in advance.
RMagick, the rails library on top of ImageMagick, can do damn near anything you need to accomplish with an image. Want to add a drop shadow to every profile picture people in your social network upload? Want to resize with a gaussian blur filter? No worries — RMagick can handle it. But you pay a price for this — RMagick is both large (heavy memory usage / slow to load) and prone to leaking memory.
If you’re just looking for simple image manipulation such as basic profile resizing and cropping then you can get just this with the Mini Me of the RMagick work — MiniMagick. And it will pretty dramatically reduce the server load when users are uploading images to your Rails app.
How to Do It
Here’s how to switch over from RMagick to MiniMagick
- Do a sudo gem install mini_magick on your development, test, staging and production boxes
- If you’re using attachment_fu (as you likely are) you need to change your processor engine to mini_magick as follows: :processor => :mini_magick,
- Now we found ourselves having issues with the way mini_magick handled geometry strings and a quick bit of Google_fu led us to this wonderful blog post by Ian Drysdale who told us how to patch into attachment_fu and change the resize routine
- Depending on your crop geometry you might need to manually fix a few images (the issue is whether or not you’re cropping around a center point or from the top).
Scaling a Rails Application
May 9, 2008While I created the Edufire Dev blog about a week ago I wasn’t quite sure what to post here. Happily my founder, Jon Bischke, pointed out that a good startup friend* of ours is having some scaling issues with their Ruby application. Jon mentioned this to us and since we don’t really have any time we can use to help them out, I thought perhaps our blogging some information on what we’ve done to scale our Rails application might be helpful.
I won’t profess that any of these points are particularly insightful per se. What we’ve been doing, over the past few months, is looking for any place where we can improve our performance / capacity making us scale better. So while I won’t say that any one of these is a magic bullet, I think collectively they certainly qualify. Here are a few of the topics we’ll be covering:
- Moving to minimagick from rmagick
- Pulling actionmailer off of form submits
- Asynchronous whenever Possible
- Indices, Indices, Indices
- Using assert_efficient_sql
- Using backup_fu to backup your database to Amazon S3
- Using Pingdom for monitoring your site’s uptime
