Settings

Theme

Using Nginx to load balance microservices

hagbarddenstore.se

38 points by hagbarddenstore 10 years ago · 10 comments

Reader

skinowski 10 years ago

"highly available web applications."

but nginx will drop traffic during reloads...

  • jhgg 10 years ago

    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.

    • skinowski 10 years ago

      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.

  • paulddraper 10 years ago

    Really? That would mean there's little difference between reload and restart.

    • skinowski 10 years ago

      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.

  • hagbarddenstoreOP 10 years ago

    I haven't seen this behaviour, got any proof of your claims?

    • skinowski 10 years ago

      Any load tester will do the trick. Network latency and client keepalives enabled will also increase likelihood of errors.

Dolores12 10 years ago

did you consider haproxy?

  • hagbarddenstoreOP 10 years ago

    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.

  • lsaferite 10 years ago

    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.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection