• 7

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

How to set the request start time with HAProxy?

I would like to measure the time of full request stack. The New Relic capture time of the middleware (e.g. java, python, ruby) and request time (See https://newrelic.com/docs/features/tracking-front-end-time). For this, I need to configure the X-Request-Start header as the request pass through the HAProxy load balance. The haproxy.cfg should look like:

backend www
  balance roundrobin
  mode http
reqadd      "X-Request-Start"  UNKNOWN_TIME_FUNCTION()
server servername weight 1 check

There is a haproxy native function to replace the UNKNOWN_TIME_FUNCTION()?

    • Out of curiosity, are you front loading your haproxy with an nginx? I'm wary of recompiling nginx with the provided patch
      • 2
    • I'm curious, @Tupy, did you ever discover a solution to this? I would also like to setup New Relic to work with HAProxy.

You can't do that right now, though it will be possible after we can pass SSL info because we'll permit to pass any dynamic information in a header. This piece of information would as well be the current time.

If you absolutely need this, it's not terribly difficult to implement in the code. Ideally it should be done in the function which is also able to send the server name in a header, so that in case of connect retry or redispatch, the time is updated, though that does not seem critical.

Oh and BTW, why don't you simply use haproxy's logs as everyone to measure your precise processing time ? It does exactly what you need with more details (eg: split connect/processing/transfer) without having to change anything in the server, and with more accuracy (having two machines synchronized at less than 1 millisecond is not easy).

  • 3
Reply Report

Trending Tags