Deploying to multiple Rails servers

6 views
Skip to first unread message

Emil Marcetta

unread,
Jan 23, 2010, 5:01:17 PM1/23/10
to WebROaR - Ruby Application Server
Hi there,

I'd like to test out WebROaR with an existing application(s). Our main
motivation is to check whether we can squeeze some performance out of
it, but I'm not sure about a few things around deployment. My
questions are below; any thoughts/ideas are appreciated.

1) Multiple backends - we run 8 Passenger/Rails Linux hosts and each
server is running 4 Rails apps. All is served from the front Apache/
ha_proxy. There are also 2 separate "job" servers that run asynch
processing and scheduled jobs (cron/beanstalkd stuff). Currently we
deploy to those 10 engines using Capistrano script with a single
command line. How does WebROaR deploys to many servers?

2) Deployment callbacks - does it support before / after callbacks?
For example things such as, "after deploy restart memcached"?

3) Migrations - Using Capistrano script we run DB migrations. How to
run migrations with WebROaR?

4) Rollback - when we screw up, and a bug makes it to the production?
How to rollback?

5) Logging - we use log4r that logs to the centralized log (syslog, DB
etc), so the logs from all the engines are accessible from the single
console. How does admin panel handles logs/exceptions from multiple
Rails servers?

6) With Passenger/Rails we use rewriting so that the static resources
are served directly from Apache, instead of invoking slow Rails
process. What are the options?

7) Large javascript and css resources from public/ are gzipped by
mod_deflate. What are the options?

8) For static resources Apache is configured (mod_expire) to set mod
expire headers (we use only If-Modified-Since - not the entity-id).
What are the options?

9) Does WebROaR recycle workers? There are many of reasons why Ruby VM
baloons (our bugs, bug in gems hint Imagemagick) and Passenger offers
settings to help with this. What are the options with WebROaR?

10) Does it make sense to mix Capistrano and WebROaR? For example,
continue to use Capistrano for the deployment and use WebROaR as the
app container?


Tons of questions I know ;), I'll stop here for now.

Thanks,
emil

Aditya Babbar

unread,
Jan 25, 2010, 3:10:21 AM1/25/10
to web...@googlegroups.com
Emil,
Thanks a lot for checking out WebROaR. Answers to your queries:

"10) Does it make sense to mix Capistrano and WebROaR? For example,
continue to use Capistrano for the deployment and use WebROaR as the
app container?"

Yes Capistrano & WebROaR make a very good combination and you can continue using it for your multiple backend deployments, callbacks, migrations and rollbacks. (Hope, this also answers your questions 1 to 4).

Here is a snippet of the recipe:

----------------
set :application, "myapp" # same application name as set in the WebROaR Admin Panel

namespace :deploy do

  desc "Start the application hosted on WebROaR"
  task :start, :roles => :app do
    run "webroar start #{application}"
  end
  
  desc "Stop the application running on WebROaR"
  task :stop, :roles => :app do
    run "webroar stop #{application}"
  end
  
  desc "Restart the application running on WebROaR"
  task :restart, :roles => :app do
    run "webroar restart #{application}"
  end

end

----------------

A point about restarting of applications: WebROaR restarts only the requested application without touching any of the other apps hosted on it. 

(Side note: We have also added the feature of 'hot deployment' where the server ensures there is a zero downtime for the application being restarted. This has been checked in to the github repository and would be available in the next gem release!)


"5) Logging - we use log4r that logs to the centralized log (syslog, DB
etc), so the logs from all the engines are accessible from the single
console. How does admin panel handles logs/exceptions from multiple
Rails servers?"

Currently, WebROaR does not work across multiple machines. Each machine would have its own WebROaR server and its Admin Panel running on it showing analytics/exceptions data for the applications running on that specific machine only.

"6) With Passenger/Rails we use rewriting so that the static resources
are served directly from Apache, instead of invoking slow Rails
process. What are the options?

7) Large javascript and css resources from public/ are gzipped by
mod_deflate. What are the options?"

You can preserve your existing rewrite rules and use mod_deflate for compressing static assets by just running WebROaR behind Apache (using mod_proxy). (HAProxy or any other load balancer is not required)

You can refer more details here:

Essentially just run WebROaR on let's say port 3000 and configure apache as a reverse proxy. You would have to use a configuration similar to the following: (Please refer Apache documentation for exact details)

------------
ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass /images !
ProxyPass /stylesheets !
ProxyPass /javascripts !
ProxyPassReverse / http://localhost:3000/

Alias /images PATH_TO_APPLICATION/public/images 
Alias /stylesheets PATH_TO_APPLICATION/public/stylesheets
Alias /javascripts PATH_TO_APPLICATION/public/javascripts
------------


"8) For static resources Apache is configured (mod_expire) to set mod
expire headers (we use only If-Modified-Since - not the entity-id).
What are the options?"

If you run WebROaR behind Apache as described above you can reuse your existing configuration for expires headers. WebROaR also supports setting of expire headers if it is serving out static assets itself. (Sidenote: WebROaR doesn't use 'ruby/rails' workers for serving static files. It uses extremely fast workers written in C for serving them.)

"9) Does WebROaR recycle workers? There are many of reasons why Ruby VM
baloons (our bugs, bug in gems hint Imagemagick) and Passenger offers
settings to help with this. What are the options with WebROaR?"

WebROaR allows for configuration of minimum and maximum number of (ruby) worker processes for any application running on it. 

Let's say for some particular application these have been set to 4 and 8. The application would start with 4 workers initially. If the application comes under sustained user load, WebROaR would automatically spawn off new workers till its maximum limit (8). Once the load has subsided, it would kill off the extra workers one by one. WebROaR kills off the worker that is using the 'maximum' memory at that point. This helps in keeping errant workers under check. 

Also, in case a worker is 'stuck' (and not responding), WebROaR automatically kills it and start another one in its place.

Hope these answers help. Please feel free to shoot us any other questions as well.

Aditya
Reply all
Reply to author
Forward
0 new messages