Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

Round-robin Django setup with nginx. An nginx trick I didn’t know: a low proxy_connect_timeout value (e.g. 2 seconds) combined with the proxy_next_upstream setting means that if one of your backends breaks a user won’t even see an error, they’ll just have a short delay before getting a response from a working server.

Tagged , , , ,

3 comments

  1. You have to be incredibly careful with proxy_next_upstream, it retries all requests, POSTs, PUTs etc.

    It's a cool way to recover from some errors but you can also end up submitting duplicate requests and doing things like double charging credit cards, duplicating blog comments etc.

    The setting in that webpage is ok I believe, but all the same, you're playing with fire...

    Michael Koziarski - 22nd December 2009 03:19 - #

  2. Good to know, thanks. Is there no way of setting it to only re-send GET requests? Might be a good feature request.

    Simon Willison - 22nd December 2009 10:46 - #

  3. Don't believe you can restrict it to GET requests right now, but yeah that would be an awesome feature request.

    Another issue is of course the 'self-dos', if someone manages to craft a request which causes your web server to close the connection, proxy_next_upstream will happily consume your backends one at a time until the request hits the timeout.

    We've changed our production systems to only try the next upstream if the connection fails. We'll notice a few errors if a process crashes, but that's rare enough it's not worth corrupting data.

    Double charging one credit card is enough to make you extra paranoid ;)

    Michael Koziarski - 22nd December 2009 22:36 - #

Sign in with OpenID

Auto-HTML: Line breaks are preserved; URLs will be converted in to links.

Manual XHTML: Enter your own, valid XHTML. Allowed tags are a, p, blockquote, ul, ol, li, dl, dt, dd, em, strong, dfn, code, q, samp, kbd, var, cite, abbr, acronym, sub, sup, br, pre

A django site