简体   繁体   中英

Phusion Passenger app preloader for Rails

I recently switched to using Phusion Passenger 4.0.50 in replacement for Unicorn. The reason is because Passenger integrates well with Nginx and can also power Node.js app. However, what I am wondering is if I should do anything about the external connections (with Postgresql, Redis, Memcached) like I did with Unicorn.

I found some code on the Passenger git such as this one . But this code seems to belong to Passenger rather than a Rails app.

As of now I am using Ruby 2.1.2, and 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.

Phusion Passenger author here. 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. 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

The only exception is the Rails default ActiveRecord connection. We automatically reestablish that, because it counts for over 90% of the use cases.

Passenger starts multiple sepearate worker processes, each of them loading the rails application. So each webrequest is handled by a completely isolated process within one thread. 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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