feat: do not entirely disable connection pooling for periodic connections - #2440
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
More details
Both HTTP backends set the same five-second idle limit for periodic clients. The changed call sites use the new periodic policy consistently.
🤖 Datadog Autotest · Commit 8d26774 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
|
✅ All CI checks and tests passed. 🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 1444009 | Docs | View more details | Give us feedback! |
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
Periodic clients (telemetry flushes, remote config polling, etc.) used to disable connection pooling entirely, which meant every request paid a full TLS handshake. That is quite costly for agentless traffic (on the order of magnitude of 0.5s per connection), and short-lived apps send several separate requests in a short span of time. Instead of disabling pooling, `new_client_periodic` now pools connections with a small idle timeout (5s), much smaller than typical keep-alive timeouts on the receiving end, so we still avoid reusing a connection the receiver may have closed.
BenchmarksComparisonBenchmark execution time: 2026-09-02 09:09:36 Comparing candidate commit 1444009 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 135 metrics, 1 unstable metrics.
|
8d26774 to
929afab
Compare
|
/merge |
|
View all feedbacks in Devflow UI.
It will be processed automatically as soon as GitHub reports it as mergeable. View in MergeQueue UI.
The expected merge time in
|
What does this PR do?
This PR slightly changes the HTTP behavior for periodic connections (most flushes to the agent/agentless intake). Instead of disabling connection pooling to avoid data races entirely, it restricts the lifetime of pooled connections.
This PR aims to be a backward-compatible hotfix. A subsequent PR is coming with renaming (since
no_connection_poolingisn't really true anymore) and mirroring the change in libdd-http-client and libdd-agent-client as well.Motivation
Mitigates APMS-20441 / DataDog/dd-trace-py#19915: some telemetry events can generate several requests for short-lived scripts. In the agentless case, this means opening several new HTTPS connection in a row, which is slow.
Additional Notes
Applying the setting to all periodic connections sounds reasonable, as multiple requests could reasonably be issued for other things than telemetry. It should impact single-request workflows.
How to test the change?
This was tested with the repro in 20441, reducing the shutdown delay to 0.750ms locally, which indicates there's indeed a single HTTPS connection (vs double before the change).