Duração da solicitação HTTP com o HAProxy

1

É possível monitorar a duração de solicitações HTTP ? (a partir do momento em que a solicitação é recebida pelo balanceador de carga, até o momento em que a resposta é retornada ao cliente pelo balanceador de carga)

Gostaria de monitorar essa métrica no frontend, porque quero incluir o tempo da fila. Se eu medir a duração do back-end, posso obter boas estatísticas, mas o desempenho real pode ser ruim (por exemplo, se a solicitação for enfileirada no próprio balanceador de carga).

Por exemplo, gostaria de monitorar um aplicativo da web durante picos de tráfego para garantir que as respostas ainda sejam rápidas, do ponto de vista do usuário (por exemplo, < 3 segundos).

    
por collimarco 16.09.2017 / 12:14

1 resposta

2

O HAproxy oferece todas essas informações nos registros.

veja Formato de registro HTTP da Haproxy

Em particular, você está procurando a seção número 6,

6 TR '/' Tw '/' Tc '/' Tr '/' Ta* 10/0/30/69/109

onde

  • "TR" is the total time in milliseconds spent waiting for a full HTTP request from the client (not counting body) after the first byte was received. It can be "-1" if the connection was aborted before a complete request could be received or the a bad request was received. It should always be very small because a request generally fits in one single packet. Large times here generally indicate network issues between the client and haproxy or requests being typed by hand. See "Timers" below for more details.

  • "Tw" is the total time in milliseconds spent waiting in the various queues. It can be "-1" if the connection was aborted before reaching the queue. See "Timers" below for more details.

  • "Tc" is the total time in milliseconds spent waiting for the connection to establish to the final server, including retries. It can be "-1" if the request was aborted before a connection could be established. See "Timers" below for more details.

  • "Tr" is the total time in milliseconds spent waiting for the server to send a full HTTP response, not counting data. It can be "-1" if the request was aborted before a complete response could be received. It generally matches the server's processing time for the request, though it may be altered by the amount of data sent by the client to the server. Large times here on "GET" requests generally indicate an overloaded server. See "Timers" below for more details.

  • "Ta" is the time the request remained active in haproxy, which is the total time in milliseconds elapsed between the first byte of the request was received and the last byte of response was sent. It covers all possible processing except the handshake (see Th) and idle time (see Ti). There is one exception, if "option logasap" was specified, then the time counting stops at the moment the log is emitted. In this case, a '+' sign is prepended before the value, indicating that the final one will be larger. See "Timers" below for more details.

Exportar essas métricas dos logs para um formato / backend mais útil pode ser feito de várias maneiras, o Logstash vem à mente, pois pode analisar esses logs e enviá-los para muitos backends diferentes

    
por 16.09.2017 / 12:24

Tags