DEV: sse-latency: add a latency measuring tool for SSE response streams
Common HTTP load generation tools are not convenient to measure latency
through haproxy when it comes to server-sent events, because the
measurements do not apply to the partial contents that SSE are. These
are particularly important for AI environments where agents need to
minimize latency.
This commit introduces a new tool that is both a client and a server,
and that is meant to measure an intermediary's added latency. For this,
it connects to itself to measure its own inflicted latency (loopback
test) then does it again through the configured proxy, and reports both
as well as the traversal time. The principle is to note the timestamp
at which each SSE is sent, and measure the difference when received by
the client, since both sides are the same process and use the same clock
reference. The output shows the reference time (loopback), the gateway
time, and the gateway overhead as the difference between the two.
The tool supports adding more clients, doing more requests, delaying the
first token response, and setting the inter-token latency.
An example haproxy config is provided (gateway.cfg) that measures both
with and without option http-no-delay.
Without http-no-delay (+ ~100ms, max 200 due to Nagle):