开发者

How do I run multiple instances of my Rails app?

You know, for load balancing, etc? I have a VPS and understand you can deploy and run multiple instances and have them share data with database session store and memcached and the like. What I have not been开发者_如何学C able to find is any information on how this is done?

I am curious about multiple instances (two or three) on a single VPS and also among multiple VPSs.

TIA,

NJ


It really depends on what architecture you're using. If you're using mongrel check out mongrel_cluster. If you're using fastcgi or passenger this is already done for you. One other way would be to look into Heroku which allows you to just change a slider bar for more instances. 45k projects are now hosted on Heroku so if you're serious about it I think you owe it to yourself to check it out.


A great book for this is Deploying Rails Applications. It's a little out of date, but gives you the full scope and foundation of the admin side of rails. It uses mongrel clusters, which will accomplish what you want.

As Chuck mentioned above, Passenger is a great option, and I think it's become more popular than Mongrel. But the book will give you a good foundation to work from. The e-book is only $22, but I bought the paper version myself.


Cloud computing is interesting. Amazon AWS allows you to boot up multiple instances of a disk image, allowing you to create a pool of workers. You can boot and shutdown machines using an API call and you are only charged for when you use them.

Getting these machines to work together is more difficult. There are distributed ruby projects but they lack important features. Quartz is a great project that I have used for distributed computing. It is a very powerful library that simplifies the coordination of tasks on a single system or a large cluster. The difference between the two comes down to a single configuration file. It is however written in Java. Java is a good choice for the project because it has a better memory manager than ruby. Have you ever tried running a ruby script for a long time? Its memory usage tends to become out of control after a few days.

In short write simple jobs in Java using Quartz that execute your ruby code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜