Using Nginx to load balance microservices
hagbarddenstore.se"highly available web applications."
but nginx will drop traffic during reloads...
This is false. Nginx will spawn new workers with the changed config and gracefully shutdown the old ones once the new ones are online. There should be no drop in traffic or dropped requests while this happens.
Before making this statement, think of how the following states can really be non-disruptively handled:
1) requests in transit to nginx (in-flight) 2) TCP handshakes just completed (not yet accepted) 3) TCP handshakes in progress (clients will retry if server doesn't RST)
Nginx cannot know if requests are in transit nor it can handle just established TCP conns. It also does not drain the backlog queue in the old processes. It simply tears down estimated 'idle' connections.
Try a test with heavy load and you will see. More network latency more errors...
That's exactly why Nginx Plus offers dynamic upstream modification features as opposed to relying on reload.
Really? That would mean there's little difference between reload and restart.
Reload runs old/new processes in parallel, so switch is super quick and new connections always land on new processes. So error rate between reload and restart is huge.
I haven't seen this behaviour, got any proof of your claims?
Any load tester will do the trick. Network latency and client keepalives enabled will also increase likelihood of errors.
did you consider haproxy?
In the cases I use this setup, HAProxy won't fit, since I route based on URL values. I do have HAProxy in front of my nginx machines though.
I actually use this exact set of software.
etcd -> confd -> HAProxy
It works great. I can dynamically route incoming traffic to groups of endpoints based on hostname.