nginx + passenger module workflow

60 views
Skip to first unread message

Ilia Zenkevich

unread,
May 4, 2015, 7:20:19 AM5/4/15
to phusion-...@googlegroups.com
Hello.

Inputs:

1) One rails app.
2) nginx (nginx version: nginx/1.6.3) + passenger (5.0.4-1)
3) multiple virtualhosts pointing to one application (punct 1)

Question is: will passenger treat it as multiple apps or as one app?




Daniel Knoppel

unread,
May 4, 2015, 10:58:03 AM5/4/15
to phusion-...@googlegroups.com
It will be both. It's 1 app in the sense that it shares the same files, but from outside it will look like multiple apps because you can get there through 2 different configs.

What exactly do you want to know? 

- Daniel

Ilia Zenkevich

unread,
May 5, 2015, 4:20:49 AM5/5/15
to phusion-...@googlegroups.com
Thanks for feedback.

I read passenger optimization guide. And question is about options like passenger_max_instances_per_app (which is global in nginx.conf) and passenger_min_instances (which is local for virtualhost ("server" block in nginx)). As I wrote, I have one rails app. For nginx I have 10 virualhosts with different domains, pointing to this app. If I set passenger_max_instances_per_app =10 and for every vhost set passenger_min_instances = 2 - how passenger will behave itself? If it treat, that every vhost is separated app, will first 5 apps occupy all pool slots and other 5 will not start?
Or passenger will treat, that vhosts is one app and everything will be ok?

понедельник, 4 мая 2015 г., 17:58:03 UTC+3 пользователь Daniel Knoppel написал:

Daniel Knoppel

unread,
May 5, 2015, 6:15:14 AM5/5/15
to phusion-...@googlegroups.com
OK, that makes the question clear. 

First of all I need to clarify that "passenger_min_instances 2" does not mean that 2 instances will be created. Instead it means that if the passenger_pool_idle_time is reached, Passenger will not shutdown the last 2 instances. So if you start your server with "passenger_min_instances 2" no apps will be started at all until users start to come (or if you specify a preload url).

Now for the passenger_max_instances_per_app. Try looking at it like this: it doesn't really matter what server block a certain request comes from, as long as the app code & configuration is the same, you can use the same app to handle the request. Passenger also does this, so passenger_max_instances_per_app 10 means that in total 10 copies of your app may be created (assuming your max pool size allows it) to handle the traffic for all 10 VirtualHosts. It doesn't matter if you have 10 or 50 VirtualHosts, and one app copy will handle requests from different VirtualHosts.

Keep in mind that if you change the (Passenger) configuration in server block the app might change. For example if one server block runs in development mode and the other in production mode Passenger cannot use 1 app to handle both so you will get 20 copies (10 of each) - again assuming the max pool size allows it.

- Daniel

Ilia Zenkevich

unread,
May 5, 2015, 8:31:23 AM5/5/15
to phusion-...@googlegroups.com
Thanks, I understand now.

One more question appeared:

inputs are the same: one rails app and many vhosts.

I understand about changing, for example passenger_app_env in server block, does it apply all server-block passenger option?
For example, every vhost has own limit for passenger_min_instances, 2,3 and 5, but other option are the same. Does passenger will create copies ?

вторник, 5 мая 2015 г., 13:15:14 UTC+3 пользователь Daniel Knoppel написал:

Daniel Knoppel

unread,
May 7, 2015, 10:02:01 AM5/7/15
to phusion-...@googlegroups.com
If you want to set different passenger_min_instances for vhosts that refer to the same app, you will need to use groups, see the explanation here:
https://github.com/phusion/passenger/issues/1501

Otherwise the minimum will constantly change between 2, 3 and 5.

- Daniel
Reply all
Reply to author
Forward
0 new messages