Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are launching a high demand (several hundred simultaneous users) Ruby on Rails application and we are trying to determine the best way to scale. Currently, we have a setup that follows this structure:

HaProxy DDoS Protected VPS -> Three Varnish Cache VPSs ---> One Thin + Sinatra + NGINX server for the actual files

The rails application is very resource intensive, both memory and CPU. I do not have nearly as much experience with Varnish or HAProxy, so I'm not sure which servers should be scaled, and which direction to scale them. I assume that I should scale horizontally (more instances of each server, and just slightly vertically) but I am not sure what industry standard practices are in a case like this. I also need to better understand where the load will fall, so if the Varnish should have more allocated resources (either servers or resources) than the HAProxy instances, for instance.

I appreciate any help with this

share|improve this question
Have the developers done any profiling to see where bottlenecks are? It's possible you may alleviate some problems by separating elements out like database access or certain elements being retrieved when they could be better cached. Many applications it's not simple to say "I have a RoR application, how should we scale it?" It's the architecture of the application, not necessarily the framework or stack, that determines how to do that. – Bart Silverstrim May 31 '14 at 1:20
The main bottleneck arises in simply serving that many people. It's not necessarily the RoR application that will need scaling, it more the other two (HAProxy and Varnish). I have a much better understanding of what I need for the RoR application, than I do for HAProxy and Varnish, because I haven't used them much in the past. So I suppose the main part of the question would be how should HAProxt and Varnish be scaled - vertically or horizontally? – Nilnoc May 31 '14 at 1:33
"The main bottleneck arises in simply serving that many people.", that's not a bottleneck. What is hitting its limits? CPU, RAM? Which servers are hitting these limits? The HAProxy, Varnish or App server? It sounds like your problem is mostly that you don't have enough oversight to answer these questions, I suggest setting up something like newrelic: – thexacre May 31 '14 at 2:15
When load increases, both CPU and RAM hit their limits. This only occurs in the HAProxy and on the Varnish Server. The RoR does not hit limits. We have done load testing with and come to those conclusions. – Nilnoc May 31 '14 at 2:31
Sounds like you need to get a bigger HAProxy server, or have multiple which are load balanced via DNS round robin, then add more Varnish cache servers. In the long run horizontal scaling will probably work out cheaper, but it's harder to horizontally scale certain things like the entry point. – thexacre May 31 '14 at 2:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.