onebyone rolling restarts moving too quickly

14 views
Skip to first unread message

wi...@justworks.com

unread,
Apr 11, 2017, 5:36:25 PM4/11/17
to thin-ruby
Hi,

We have a setup where nginx sits in front of 2 thin servers, and during deploys restarts the one on port 9000, then restarts the one on port 9001.  We are using the onebyone option and driving the deploy with capistrano.  It appears that what happens is thin stops the 9000 server, starts the 9000 server, and then as soon as it can get a socket moves on and takes down the 9001.  Unfortunately it seems like there is some gap in between being able to get a socket (https://github.com/macournoyer/thin/blob/a7d1174f47a4491a15b505407c0501cdc8d8d12c/lib/thin/controllers/cluster.rb#L82) and being responsive as an app server (maybe this is the rails environment loading?).  This results in both of our servers being nonresponse at once and causes nginx to serve 502s for about 2-300ms during deploys.

Here is our server config:
---
chdir: /var/www/current
address: 0.0.0.0
port: 9000
timeout: 30
log: log/thin.log
pid: tmp/pids/thin.pid
max_conns: 1024
max_persistent_conns: 100
require: []
wait: 60
user: www-data
group: www-data
daemonize: true
onebyone: true
servers: 2

Questions:
1. Is there something obvious we are doing wrong?
2. Is there some way to add a few seconds pause before taking down the next server?
3. If we were able to find a more reliable way to determine if a rails server was responsive would you be interested in a patch?

Thanks,
Will
Reply all
Reply to author
Forward
0 new messages