How to scale Rails

So we established previously that Rails really can scale!  Now it’s time to look at how to do it.  I’ll list here the basic steps and then follow up with a post on each of these:

  1. Of course, Memcached helps a ton!
  2. Start with a master database and add two or three slave databases.  Split your reads from your writes. Rails has a great plugin for this that makes it about as easy as it can be (certainly easier than PHP). This will move you to being able to handle 15 or so app servers.
  3. Denormalize some of your data to reduce query intensity.
  4. Shard your data. Put statistics/usage data on a totally separate set of DB boxes from your user’s data.  If you really are the next MySpace,  check out AsterData for offloading some of that work.
  5. Switch to a commercial DB setup. If you’re still desperate to expand, then a more robust DB is probably in order. The great part: Rails is database agnostic (at least far more so than PHP or ASP) and will happily switch without too much effort.
Advertisements