Repository navigation
fix(executor): reuse connections to the executor across calls - #14214
HarshMN2345 wants to merge 1 commit into
Conversation
Executor::call() opened a new curl handle for every request, so each execution left a TIME_WAIT socket in the API container. A persistent share keeps idle connections in the worker. The executor service also reuses outgoing TIME_WAIT ports until its image pools connections to runtimes.
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
|
@hansi-codes review |
🟢 Tier S · Ready to merge
The executor client now shares DNS and idle TCP connections across calls while keeping a separate easy handle for each request. The Compose executor service enables outgoing TIME_WAIT port reuse, and new tests exercise sequential connection reuse and reconnection after a server closes a socket.
📂 Walkthrough · 3
Reviewed |
What does this PR do?
Fixes the Appwrite side of #14094.
Executor::call()built a new curl client for every request and forbade connection reuse, so each execution opened a TCP connection to the executor and left it inTIME_WAIT. Under sustained load that fills the API container's source-port range and throughput falls to whatTIME_WAITexpiry allows.Each call still gets its own easy handle, so concurrent coroutines never share a busy transfer. A process-wide curl share (
CURL_LOCK_DATA_CONNECTandCURL_LOCK_DATA_DNS) keeps idle connections, andwithConnectionReuse()stops the adapter from closing the socket when the handle is discarded.The executor image still dials a runtime per execution (
open-runtimes/executor#259). Until that ships, the executor service setsnet.ipv4.tcp_tw_reuse=1. That only affects outgoing connects. The kernel default (2) reusesTIME_WAITports for loopback only, which is why the executor's port search pegs a core after the first burst.Test Plan
tests/unit/Executor/ConnectionReuseTest.phpdeleteRuntimecalls against a keep-alive server accept one TCP connection.vendor/bin/pint --teston the changed PHP files.src/Executor/Executor.phpand the new test.Related PRs and Issues
Checklist