fix(fpc): remove keepalive — fphttpserver poll interval causes ~40ms per-request stall - #554
fix(fpc): remove keepalive — fphttpserver poll interval causes ~40ms per-request stall#554freitasjca wants to merge 7 commits into
Conversation
…per-request stall
|
Obrigado pelos dados de desempenho e pela investigação do intervalo de aproximadamente 40 ms. Este PR ainda não está pronto para revisão porque mistura duas linhas de trabalho diferentes e altera a semântica HTTP/1.1 do provider padrão. Antes de prosseguirmos, por favor:
Depois da limpeza, precisamos reavaliar o trade-off entre latência, persistência HTTP/1.1 e compatibilidade dos clientes antes de aprovar. |
|
Obrigado pela investigação e pelos benchmarks apresentados. A alegação de latência com o keep-alive do Este PR, porém, não pode ser integrado no estado atual pelos seguintes motivos:
Além disso, a implementação do FPC usa Vamos continuar essa análise na #562. Se a causa for confirmada no Horse, faremos uma correção isolada, preservando a semântica HTTP/1.1; se estiver no |
Summary
FPC-KEEPALIVE-1enabledKeepConnections=Trueon the embedded fphttpserver to restore HTTP/1.1 keep-alive semantics. This produces a ~40 ms stall on every request — a 93× regression on Linux affecting every FPC user running Horse with the default provider.Root cause
fphttpserver's
TFPHTTPConnectionThreadkeep-alive loop callsselect(fd, ~40 ms)between requests to poll for graceful-shutdown signals. Even when the next request is already queued, the loop waits one full interval. This is a fixed constant in fphttpserver — it cannot be configured from outside.Evidence
Measured with h2load
-n 50000 -c 1on Linux (FPC trunk 3.3.1):TCP_NODELAY was applied simultaneously and had zero effect, confirming the cause is the poll interval, not Nagle/delayed-ACK.
What this PR does
EnableServerKeepAlive—KeepConnectionsreverts toFalse(fphttpserver default).EnableServerNoDelay(PATCH-FPCHTTP-2) — setsTCP_NODELAYon every accepted socket viaTSocketServer.OnAllowConnect. Avoids Nagle on non-loopback links. Guard: FPC ≥ 3.3.1, UNIX only.FPCHttpKeepaliveTest.dpr— standalone FPC regression test: 30 sequential requests must complete in ≤ 35 ms each.Trade-off
With
KeepConnections=False, clients that reuse a connection after the server closes it receiveECONNRESET. Most clients (curl, browsers,System.Net.HttpClient) reconnect transparently. Connection pools that do not retry stale connections should be configured to do so, or to disable keep-alive with this provider.