views:

36

answers:

1

I have a Rails app whose major part is to query another web-service using ActiveResource and show the results to the users. But it uses the database for other features like user-login , reviews comments etc. When the mysql database goes down , the whole app goes down. In such cases i want have atleast the part which doesnt require the database. (the one which uses ActiveResource and get the results from the webservice) be functional. as it is the major thing for my Rails app.

What are the ways i can accomplish this. ? To start the app without db i googled , where i got to know i should exclude ActiveRecod from the list of frameworks in the environment.rb file. But it wouldnt start cos there were so many reference the database all through my app.

so could i make a version of the app which doesnt require db and route the request to this version when ever the db goes down?

or

Is there anyway to just disable the database accessing part and make the webservice part running. when the database goes down?

Thanks

+1  A: 

you can bind your full app at port, say, 4000, and your web-service-only app at port 4001, and then put some kind of reverse proxy before them (usually on port 80). nginx or haproxy.

Both nginx & haproxy have options like 'server pools', so it will first try port 4000, and if it's down then it will try next 4001.

Also proxies can be easily configured to always route specified URI paths to port 4001, and all other to 4000.

zed_0xff
I already have apache as a proxy server infront of the mongrels. can apache do things u had mentioned?
railscoder
It can. But it's much harder to configure.
zed_0xff