简体   繁体   English

适用于Rails的Phusion Passenger应用预加载器

[英]Phusion Passenger app preloader for Rails

I recently switched to using Phusion Passenger 4.0.50 in replacement for Unicorn. 我最近改用Phusion Passenger 4.0.50替代了Unicorn。 The reason is because Passenger integrates well with Nginx and can also power Node.js app. 原因是因为Passenger与Nginx集成良好,并且还可以为Node.js应用程序提供支持。 However, what I am wondering is if I should do anything about the external connections (with Postgresql, Redis, Memcached) like I did with Unicorn. 但是,我想知道的是,是否应该像对待Unicorn一样对外部连接(使用Postgresql,Redis,Memcached)做任何事情。

I found some code on the Passenger git such as this one . 我发现在旅客git的一些代码,如这一个 But this code seems to belong to Passenger rather than a Rails app. 但是此代码似乎属于乘客而不是Rails应用。

As of now I am using Ruby 2.1.2, and Rails 4.1.6. 到目前为止,我正在使用Ruby 2.1.2和Rails 4.1.6。 Would such work to handle external connections still required? 是否仍需要进行此类工作来处理外部连接? If it is, how should I do it? 如果是,该怎么办?

Thanks. 谢谢。

Update: 更新:

Per this thread , it seems that normal ActiveRecord is taken cared of automatically by Passenger. 通过这个线程 ,似乎正常的ActiveRecord是由Passenger自动维护的。

Phusion Passenger author here. Phusion乘客作者在这里。 Yes you must do something about external connections. 是的,您必须对外部连接做一些事情。 The "smart spawning" concept in Phusion Passenger is exactly the same as the "preload_app on" concept in Unicorn. Phusion Passenger中的“智能生成”概念与Unicorn中的“ preload_app on”概念完全相同。 We have an entire section in the documentation explaining how it works and what the caveats are (specifically, about external connections): https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#spawning_methods_explained 我们在文档中有一整节内容,说明了它的工作方式以及注意事项(特别是有关外部连接): https : //www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#spawning_methods_explained

The only exception is the Rails default ActiveRecord connection. 唯一的例外是Rails的默认ActiveRecord连接。 We automatically reestablish that, because it counts for over 90% of the use cases. 我们会自动重新建立它,因为它占用例的90%以上。

Passenger starts multiple sepearate worker processes, each of them loading the rails application. 乘客启动了多个独立的工人流程,每个流程都在加载Rails应用程序。 So each webrequest is handled by a completely isolated process within one thread. 因此,每个Web请求都由一个线程内的完全隔离的进程处理。 This means you don't have to care about connection pools at all. 这意味着您根本不必关心连接池。 For example, in case of ActiveRecord, there are 5 concurrent connections possible by default (can be adjusted) and in your case you allways have only one connection (per process) 例如,对于ActiveRecord,默认情况下可能有5个并发连接(可以调整),并且在您的情况下,您始终只有一个连接(每个进程)

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

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