Page MenuHomePhabricator

Investigate nginx reload behavior
Closed, ResolvedPublic

Description

There's a hourly drop in established connections on all text/upload hosts due to the update-ocsp-all cron job, which unconditionally reloads nginx with /etc/update-ocsp.d/hooks/nginx-reload. See for example cp3040.

The rate of TCP resets and segment retransmissions also shows short spikes during the reloads.

I was under the impression that nginx would perform fully seamless reloads by first creating N new worker processes responsible for handling incoming connections and then waiting for the connections serviced by the processes still running the old config to finish before terminating the processes themselves. Unless I'm missing something, we shouldn't see those drops/spikes in the graphs if that mechanism would work properly?

Event Timeline

• ema triaged this task as Medium priority.May 5 2017, 10:38 AM
• ema added projects: SRE, Traffic.

How timely! The subject of how to do completely-seamless reloads (especially for TCP) is quite thorny. I've been pondering it and fighting with the issues for years on the UDP side for gdnsd too. And then just yesterday, an HAProxy blog post popped up that goes into the whole thing in great detail with their own struggles and final solution, which (along with lots of other interesting details) is that nothing will be perfect unless you do SCM_RIGHTS handoff over a unix socket. I think nginx isn't doing that, they're still doing SO_REUSEPORT-based takeover. https://www.haproxy.com/blog/truly-seamless-reloads-with-haproxy-no-more-hacks/

Also note from that lengthy post - if we were willing to test the scalability of iptables on cache hosts (which we've avoided for fear that it won't scale over cores like the rest of what we're doing) and it works out, there are iptables hacks around this where you temporarily block new SYNs or dataless ACKs around the quick reload, which might work with nginx's methods.

Hmmm another thing - when we first deployed this OCSP updating method, GlobalSign was giving us 8-hour OCSP validity windows. At present (just checked) we're getting 4-day validity from GlobalSign and 7-day validity from Digicert. Perhaps we should back off the OCSP timing from once an hour to once a day in light of this, and use cron_splay instead of fqdn_rand while we're at it?

Change 352134 had a related patch set uploaded (by BBlack; owner: BBlack):
[operations/puppet@production] ocsp updater: 1/day instead of 1/hr

https://gerrit.wikimedia.org/r/352134

Change 352134 merged by BBlack:
[operations/puppet@production] ocsp updater: 1/day instead of 1/hr

https://gerrit.wikimedia.org/r/352134

Change 352185 had a related patch set uploaded (by BBlack; owner: BBlack):
[operations/puppet@production] Align OCSP file freshness check with new cron timing

https://gerrit.wikimedia.org/r/352185

Change 352185 merged by BBlack:
[operations/puppet@production] Align OCSP file freshness check with new cron timing

https://gerrit.wikimedia.org/r/352185

• ema claimed this task.

Closing, the problem is known and there's no perfect solution (but one nginx reload a day is much better than one every hour!).