fix(fpc): remove keepalive — fphttpserver poll interval causes ~40ms per-request stall - #554
Open
freitasjca wants to merge 7 commits into
Open
fix(fpc): remove keepalive — fphttpserver poll interval causes ~40ms per-request stall#554freitasjca wants to merge 7 commits into
freitasjca wants to merge 7 commits into
Conversation
…per-request stall
Contributor
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.