On Wed, Apr 9, 2014 at 9:58 PM, Kai Krakow <
hurik...@gmail.com> wrote:
> Hongli,
>
> When I posted that solution to SO, my understanding of Passenger's
> architecture was this:
>
> Passenger preloads the Rails stack of an app, this becomes the master
> Master will be preinitialized, which means DB connections will open (thus
> opening FDs)
> Master may prelaunch an app instance now by forking, or fork on demand by
> web request
> On fork, open FDs be cloned and are shared now with the master instance
> Due to forking, the pool is shared amongst all instances of the SAME
> Passenger app
1-4 are about right. 5 is not right.
For one, the pool is not shared. Normally, such forking will cause
file descriptors to be shared. But file descriptors are not the pool.
They're just the connection. There is no way to share the pool between
processes (even processes belonging to the same app), because the pool
is an in-memory data structure, not a kernel resource.
Second, Phusion Passenger resets the Active Record connection after
forking, specifically to address this issue in the common case. Only
additional connections that the app made outside of Active Record,
will not be reset by Phusion Passenger.
So you are correct in that some resources are shared. Although that
doesn't mean the shared resources work properly.
--
Phusion | Web Application deployment, scaling, and monitoring solutions