Scaling a Rails app (Part 1 of 3) no comments

Posted by stephane Wed, 10 Oct 2007 18:32:53 GMT

One of the most interesting topic in the RailsConf was Scaling your Rails app. There are 2 ways of doing it:

  • adapt your code
  • adapt your servers

But the second one will not help to make your code faster. It will just help to give maximum resources to compute it right.

Summaries from the conference (sorry for the so few litterature it will be only a summarize):

Some theories

These theories are for big websites with millions of hits every month. This can involve thousand of servers, different location, ... BTW some tips can be use to help smaller configurations.

The 7 layers to be considered, a la OSI.

  • DNS
  • frontend
  • proxy
  • application server
  • application
  • backend (Db , filesystem)
  • OS

DNS

Nice website to check your DNS configuration: dnsstuff.com Good tool to optimize your DNS: speed, dispatching, and so on…: powerdns

DNS can be quite fast to address the right server from a request, scripts allow to manage complex configurations. The tip is to use 1 DNS entry per 1 controller, then managing part of the routing.

Frontend and Proxy

Load balancing is about dispatching requests taking in account the charge of each cluster.

Load balancers: Varnish HAProxy

Both look promising and HAProxy seems to be more and more popular.

Front end with load balancer: Nginx : fast, low memory usage, http server with load balancing, easy configuration, very good in front of mongrel cluster. Apache 2.2 + mod_proxy_balancer, you can find how to setup it in previous post: apapche, mongrel cluster, rails on a load balancer

Application server

  • mongrel server: enough for a personnal server gem install mongrel mongrel_rails start (more information)
  • mongrel_cluster: useful to scale up your configuration, need at least a multi-processor or multi server environnment. gem install mongrel_cluster mongrel_rails cluster::configure … mongrel_rails cluster::start
  • Evented Mongrel (swiftiply): it’s a mongrel based an event triggering
  • jruby / glassfish: the technology java comes with some good environment to speed up part of your application like connection to database (jdbc, pool connection)

to be continued (application, backend, OS, and some home benchmark)

Comments

Leave a response

Comments