I am developing a Ruby On Rails application and would like to deploy in a production environment. I have multiple identically configured Ubuntu web servers I can use but I don't know how to scale the RoR app and db data across multiple hosts.
I'd like to put both a web server and a db server on each host.
On the web server/ruby middleware side, I'd like sessions to be controlled by a master web server that does load balancing on the web server/ruby middleware layers. It should hand off new sessions to free hosts.
I need to have load balancing in place on the web server/ruby middleware side. Web/middleware sessions should be atomic (I'm not interested in replicating them across multiple hosts)
I'd like to have the transactional data that has not been saved to the DB logged to an intermediate redo-log -- to be re-run in case of failure-recovery.
In the DB layer:
I'd like to have the DB data on any one host to be replicated to 2 other hosts. (each DB set has 3 DB hosts)
I don't want to have the DB data replicated across all hosts because it takes too long -- latency.
I'd like to put an algorithm into place that will direct 'create'-type requests to the right DB. Load balancing comes to mind.
The DB master controller should know which 3-DB set to go to for 'update/read/delete' requests.
My test web server is webrick and the backend DB is Postgresql (though this really doesn't matter with RoR).
I believe I need to tie a sessionId to each transaction and also keep a redo-log in case I need to re-load that session after a failure.
What other design issues am I likely to run into? Also, what web server and DB server should I use to do the grunt work? What are good choices for the master DB and master web servers?
I understand this is a complicated problem that spans across multiple domains of knowledge. I'd like to know if what I'm asking is possible.