I recommend checking out Enterprise Rails by one of my former
coworkers, Dan Chak:
He describes a lot of the work we did at CourseAdvisor to scale our
site to handle millions of users. I think Rails has evolved to a point
where some of the approaches he describes are not the best, but I
think it still contains some very helpful advice and strategies. (I'm
not involved with the book in any way so this is not self-promotion).