简体   繁体   English

如何运行Rails应用程序的多个实例?

[英]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. 我有一个VPS,并且了解您可以部署和运行多个实例,并使它们与数据库会话存储和memcached等共享数据。 What I have not been 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. 我对单个VPS以及多个VPS中的多个实例(两个或三个)感到好奇。

TIA, TIA,

NJ NJ

It really depends on what architecture you're using. 这实际上取决于您使用的体系结构。 If you're using mongrel check out mongrel_cluster. 如果您使用的是mongrel,请查看mongrel_cluster。 If you're using fastcgi or passenger this is already done for you. 如果您使用的是fastcgi或passenger,这已经为您完成了。 One other way would be to look into Heroku which allows you to just change a slider bar for more instances. 另一种方法是查看Heroku,它允许您只为更多实例更改滑块。 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. 现在在Heroku上托管了45,000个项目,因此如果您对此很认真,我认为您应该自己检查一下。

A great book for this is Deploying Rails Applications . 关于这方面的一本好书是Deploying Rails Applications It's a little out of date, but gives you the full scope and foundation of the admin side of rails. 它有点过时了,但是为您提供了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. 正如Chuck所说,“乘员”是一个不错的选择,我认为它比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. 电子书只有22美元,但我自己买了纸质版本。

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. Amazon AWS允许您启动磁盘映像的多个实例,从而允许您创建工作池。 You can boot and shutdown machines using an API call and you are only charged for when you use them. 您可以使用API​​调用来启动和关闭计算机,并且仅在使用计算机时付费。

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. Quartz是我用于分布式计算的一个很棒的项目。 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编写的。 Java is a good choice for the project because it has a better memory manager than ruby. Java是该项目的不错选择,因为它具有比ruby更好的内存管理器。 Have you ever tried running a ruby script for a long time? 您是否尝试过长时间运行ruby脚本? 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. 简而言之,使用Quartz用Java编写执行作业代码的简单作业。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM