天天看點

haproxy的timout參數

第一個參數:timeout queue <timeout>

  Set the maximum time to wait in the queue for a connection slot to be free

 設定一個連接配接位置在一個隊列中等待被釋放的最大時間。

  When a server's maxconn is reached, connections are left pending in a queue

  which may be server-specific or global to the backend. In order not to wait

  indefinitely, a timeout is applied to requests pending in the queue. If the

  timeout is reached, it is considered that the request will almost never be

  served, so it is dropped and a 503 error is returned to the client.

當一個伺服器的最大連接配接到達時,連接配接會被放在隊列中,它可能是具體的伺服器或者全局對于背景。為了不無限期的等待,在一個隊列中逾時會被用到請求挂起。如果達到逾時,被認為請求幾乎不被服務,是以請求會被丢掉并且傳回503到用戶端。

  The "timeout queue" statement allows to fix the maximum time for a request to

  be left pending in a queue. If unspecified, the same value as the backend's

  connection timeout ("timeout connect") is used, for backwards compatibility

  with older versions with no "timeout queue" parameter.

"timeout queue"這個語句允許固定請求在隊列中挂起的最大時間。如果是沒有指定,那麼和背景連接配接逾時"timeout connect"的值相同。

第二個參數:

timeout server <timeout>

  Set the maximum inactivity time on the server side.

設定在伺服器一側的最大非活動時間。

  The inactivity timeout applies when the server is expected to acknowledge or

  send data. In HTTP mode, this timeout is particularly important to consider

  during the first phase of the server's response, when it has to send the

  headers, as it directly represents the server's processing time for the

  request. To find out what value to put there, it's often good to start with

  what would be considered as unacceptable response times, then check the logs

  to observe the response time distribution, and adjust the value accordingly.

當伺服器希望接收或者發送資料的時候,非活動逾時會被應用。

它直接代表伺服器的處理請求時間。

為了弄清楚應該放什麼值,最好是從不可接受的響應時間着手,并相應的調整該值。

 In TCP mode (and to a lesser extent更小來說, in HTTP mode), it is highly

  recommended that the client timeout remains equal to the server timeout in

  order to avoid complex situations to debug. Whatever the expected server

  response times, it is a good practice to cover at least one or several TCP

  packet losses by specifying timeouts that are slightly above multiples of 3

  seconds (eg: 4 or 5 seconds minimum). If some long-lived sessions are mixed

  with short-lived sessions (eg: WebSocket and HTTP), it's worth considering

  "timeout tunnel", which overrides "timeout client" and "timeout server" for

  tunnels.通過制定逾時略微高于3秒的倍數(最小是4秒或者5秒)來解決至少一個或者多個tcp包的丢失。

如果是一些長會話混合了一些短會話,最好考慮"timeout tunnel"。

  This parameter is specific to backends, but can be specified once for all in

  "defaults" sections. 可以在“defaults”區域一次性指定。

This is in fact one of the easiest solutions not to

  forget about it. An unspecified timeout results in an infinite timeout, which

  is not recommended. Such a usage is accepted and works but reports a warning

  during startup because it may results in accumulation of expired sessions in

  the system if the system's timeouts are not configured either.

  This parameter replaces the old, deprecated "srvtimeout". It is recommended

  to use it to write new configurations. The form "timeout srvtimeout" is

  provided only by backwards compatibility but its use is strongly discouraged.

第三個參數:

timeout client <timeout>

timeout clitimeout <timeout> (deprecated)

  Set the maximum inactivity time on the client side.

 設定用戶端側的最大非活動時間。

  The inactivity timeout applies when the client is expected to acknowledge or

  send data. In HTTP mode, this timeout is particularly important to consider

  during the first phase, when the client sends the request, and during the

  response while it is reading data sent by the server. That said, for the

  first phase, it is preferable to set the "timeout http-request" to better

  protect HAProxy from Slowloris like attacks. 

It is a good practice to cover one or several TCP packet

  losses by specifying timeouts that are slightly above multiples of 3 seconds

  (eg: 4 or 5 seconds). If some long-lived sessions are mixed with short-lived

  sessions (eg: WebSocket and HTTP), it's worth considering "timeout tunnel",

  which overrides "timeout client" and "timeout server" for tunnels, as well as

  "timeout client-fin" for half-closed connections.

  This parameter is specific to frontends, but can be specified once for all in

  "defaults" sections. This is in fact one of the easiest solutions not to

本文轉自chenzudao51CTO部落格,原文連結:http://blog.51cto.com/victor2016/1906570 ,如需轉載請自行聯系原作者

繼續閱讀