Database connection limits

23 views
Skip to first unread message

David Smalley

unread,
Jan 12, 2009, 7:07:37 AM1/12/09
to Phusion Passenger Discussions
Hi there,

I have a slightly tricky problem I've been trying to solve. We have a
limit on the number of database connections that a particular user can
have open to mysql at any one time. Setting the max instances so that
it doesn't exceed this number works well, the problem is that after a
deploy the new processes cannot connect to the database because the
old processes are holding onto the connections until they time out.

I followed the instructions on killing the "Passenger spawn server" on
each restart instead of touching tmp/restart.txt - but I just wanted
to check if this is the ideal situation. Would we be better to pkill

Passenger ApplicationSpawner: <path>
&
Rails: <path>

Any advice on the best way to immediately close all database
connections without killing everything related to passenger is most
appreciated.

Thanks,

David

Hongli Lai

unread,
Jan 12, 2009, 10:35:32 AM1/12/09
to phusion-...@googlegroups.com

Yes, it is safe to kill the ApplicationSpawner processes and the Rails
processes.

--
Phusion | The Computer Science Company

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

David Smalley

unread,
Jan 12, 2009, 11:17:51 AM1/12/09
to Phusion Passenger Discussions
On Jan 12, 3:35 pm, Hongli Lai <hon...@phusion.nl> wrote:
> Yes, it is safe to kill the ApplicationSpawner processes and the Rails
> processes.

Is it better to leave the Passenger spawn server process alone then?
Or do I have to kill all 3 (Passenger spawn server, ApplicationSpawner
and Rails: ...) to be sure the database connections are freed up?

Thanks,
David



Hongli Lai

unread,
Jan 12, 2009, 11:20:15 AM1/12/09
to phusion-...@googlegroups.com

You only need to kill the ApplicationSpawner and Rails processes.

David Smalley

unread,
Jan 13, 2009, 6:50:16 AM1/13/09
to Phusion Passenger Discussions


On Jan 12, 4:20 pm, Hongli Lai <hon...@phusion.nl> wrote:
> You only need to kill the ApplicationSpawner and Rails processes.

For anyone interested in achieving the same thing, we have now set the
Brightbox gem up to perform a restart like this

desc "Hard restart your passenger instances by killing the
dispatcher"
task :hard_restart, :roles => :app, :except => {:no_release =>
true} do
soft_restart
run "pkill -f '^Rails: #{deploy_to}' || true"
run "pkill -f '^Passenger ApplicationSpawner: #{deploy_to}' ||
true"
end

Which seems to have the desired effect of immediately freeing up
database connections.

Thanks,

David
Reply all
Reply to author
Forward
0 new messages