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 , , , ,

7 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 - #

  4. Articles like this are an example of quick, helfpul answers.

    Nelly - 16th August 2011 21:40 - #

  5. This is eaxctly what I was looking for. Thanks for writing!

    Wimpy - 9th September 2011 10:57 - #

  6. I will recommend my friends to read this. Bottes UGGI am quite sure they will UGG Pas Cher learn lots of new stuff here than anybody else!

    ugg pas cher - 29th October 2011 02:50 - #

  7. I think we need to bring more ideas for this purpose. Involvement of young people can be handy in this regard. I am happy to find a good post here. Thank you Cheap Online Shopping Sites

    Groundless - 1st November 2011 06:37 - #

Comments are closed.
A django site