I have a web app with different tiers:

  • database for persistence
  • a couple of web servers(mongrels)
  • load balancer

Now it is all running on the same host. But how can I add another server to handle higher load?

Should I separate roles (db & web) before scaling out any further?

P.S. let's simplify the question and ignore High-Availability issues in this question.

P.P.S. database is not a bottleneck right now. I really want to add more web servers, please help

  • Are you asking for instructions on how to split your roles with the technologies you have, or just asking a more general question of whether you should seperate your roles (db & web) before scaling out any further? – Chris Thorpe Sep 4 '10 at 12:55
  • 2Chris: good point, my mistake! It is a general question of whether you should seperate your roles (db & web) before scaling out any further. Question has been clarified. – user45286 Sep 4 '10 at 13:22

@gotts: The canonical way of scaling out small websites looks something like this:

First: Split to 2 servers, one that runs your HTTP server & web application code (webapp), and one for your database. The database server should be optimized for database workloads, i.e. lots of RAM, fast disk I/O, fast CPU.

Then: Offload static file serving from the webapp server, either to a different server, or to a Content Delivery Network. Consider disabling HTTP KeepAlive on the webapp server.

Then: Move to a setup with at least 4 servers:

  • One HTTP load balancer at the front, using consistent hashing based on source IP address.
  • Behind the HTTP load balancer, 2 webapp servers.
  • Behind the webapps, 1 Database server.

This presentation by Brad Fitzpatrick shows a typical progression on its first pages. If all this is new to you, perhaps you should consider hiring a sysadmin who has done this before... :-)


Now it is all running on the same host

Stupid idea, or? I mean - what the heck does a LOAD BALANCER do in the list if there is only one host to start with? This is the one item that makes absolutely no sense to me.

  • Separate roles first. Esepcially as the requirements are vastly different (larger DB needs a lot more IOPS which means many discs).

  • Then reprogram so that multiple web servers can easily coexist.

  • Finally add a load balancer if needed, or use DNS round robin.

  • Mongrel is a process based Ruby application server. It is common best practice in the Ruby world to place a fast HTTP server (nginx, Apache) in front of several Mongrels to add lightweight connection handling and fast static file serving. – Jesper M Sep 4 '10 at 14:34

For security and performance, I would be inclined to push the incoming http handling into a presentation tier (1 or more servers). Static content can be served in the presentation tier. Also your database / business logic is less exposed to attacks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.