{"action":"created","issue":{"url":"https://api.github.com/repos/mholt/caddy/issues/1135","repository_url":"https://api.github.com/repos/mholt/caddy","labels_url":"https://api.github.com/repos/mholt/caddy/issues/1135/labels{/name}","comments_url":"https://api.github.com/repos/mholt/caddy/issues/1135/comments","events_url":"https://api.github.com/repos/mholt/caddy/issues/1135/events","html_url":"https://github.com/mholt/caddy/pull/1135","id":179055983,"number":1135,"title":"proxy: Improve failover logic and retries","user":{"login":"mholt","id":1128849,"avatar_url":"https://avatars.githubusercontent.com/u/1128849?v=3","gravatar_id":"","url":"https://api.github.com/users/mholt","html_url":"https://github.com/mholt","followers_url":"https://api.github.com/users/mholt/followers","following_url":"https://api.github.com/users/mholt/following{/other_user}","gists_url":"https://api.github.com/users/mholt/gists{/gist_id}","starred_url":"https://api.github.com/users/mholt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mholt/subscriptions","organizations_url":"https://api.github.com/users/mholt/orgs","repos_url":"https://api.github.com/users/mholt/repos","events_url":"https://api.github.com/users/mholt/events{/privacy}","received_events_url":"https://api.github.com/users/mholt/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2016-09-24T22:39:06Z","updated_at":"2016-10-10T19:59:04Z","closed_at":"2016-09-27T23:53:44Z","pull_request":{"url":"https://api.github.com/repos/mholt/caddy/pulls/1135","html_url":"https://github.com/mholt/caddy/pull/1135","diff_url":"https://github.com/mholt/caddy/pull/1135.diff","patch_url":"https://github.com/mholt/caddy/pull/1135.patch"},"body":"This PR should fix #1069 and resolve a few other outstanding irritants in proxy behavior for backends that are less-than-robust. In summary:\r\n\r\n- Proxy no longer retries by default when a request fails, because `tryDuration` (now a configurable value on the Upstream itself) defaults to 0. This means that, by default, the downstream client must retry their request when a host initially goes down or no hosts are available.\r\n\r\n- New configuration subdirectives: `try_duration` and `try_interval`. try_duration specifies how long to try selecting hosts (used to be 60s) until one succeeds. The introduction of try_interval (with a default of 1s) is there to prevent tight loops that spin the CPU in case all the requests fail gloriously fast; this also operates under the assumption that hosts won't likely come back up within a fraction of a second and that a client can wait 1s when an upstream host initially goes down.\r\n\r\n- fail_timeout now defaults to 0, which means that request failure counting is disabled. In other words, a failed request does not count against the upstream host's availability. Since max_fails defaults to 1 (which is sensible), a single request failure could mark the upstream host down for every client for 10 seconds. This is still the case, but now the user has to opt-in to this behavior.\r\n\r\n- max_fails can no longer be < 1. People used to set this to 0 to work around the sporadic failures or \"long-lived\" downtime (of 10 seconds) even if the actual downtime may have been a fluke or a second or two. This resulted in the CPU spinning in a loop and 10s of \"502 Bad Gateway\" even though the host came up 9 seconds earlier. Anyway, this value is now irrelevant if fail_timeout is 0. The user has to explicitly enable fail_timeout in order to count request failures.\r\n\r\n- We report the actual backend error rather than \"unreachable backend\".\r\n\r\nI have also [updated the proxy docs](https://github.com/caddyserver/caddyserver.com/commit/06f46e3875a347efabd34bb8b839c4e467497861) in an attempt to be clearer in what these parameters do.\r\n\r\n@nemothekid: Would love to have your review/approval on this! :smile:"},"comment":{"url":"https://api.github.com/repos/mholt/caddy/issues/comments/252730578","html_url":"https://github.com/mholt/caddy/pull/1135#issuecomment-252730578","issue_url":"https://api.github.com/repos/mholt/caddy/issues/1135","id":252730578,"user":{"login":"jazoom","id":8279246,"avatar_url":"https://avatars.githubusercontent.com/u/8279246?v=3","gravatar_id":"","url":"https://api.github.com/users/jazoom","html_url":"https://github.com/jazoom","followers_url":"https://api.github.com/users/jazoom/followers","following_url":"https://api.github.com/users/jazoom/following{/other_user}","gists_url":"https://api.github.com/users/jazoom/gists{/gist_id}","starred_url":"https://api.github.com/users/jazoom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jazoom/subscriptions","organizations_url":"https://api.github.com/users/jazoom/orgs","repos_url":"https://api.github.com/users/jazoom/repos","events_url":"https://api.github.com/users/jazoom/events{/privacy}","received_events_url":"https://api.github.com/users/jazoom/received_events","type":"User","site_admin":false},"created_at":"2016-10-10T19:59:04Z","updated_at":"2016-10-10T19:59:04Z","body":"I'd be pretty surprised if all the backends were that flaky since there are 3 of them connected over a Digital Ocean private network, and a completely separate cluster connected over a Vultr private network (all direct via private IP). All of this worked with no bad gateway errors until the day I switched from HAProxy to Caddy. I would just switch back but I believe in this project and it's a pain to set up Let's Encrypt with HAProxy.\r\n\r\nI'll try increasing max_fails."}}
{"actor":{"display_login":"jazoom"}}