Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/trace/api: limit simultaneous otlp requests, do not drop payloads #23085

Merged
merged 6 commits into from
Feb 26, 2024

Conversation

knusbaum
Copy link
Contributor

@knusbaum knusbaum commented Feb 22, 2024

What does this PR do?

This commit causes the Trace Agent OTLP Receiver to not drop traces when the payload channel is full.

This commit also limits the number of simultaneous RPC requests, forwarding the backpressure from the pipeline to the client, and limiting our memory to O(MaxConnections * MaxStreams * MaxPayloadSize) in the receiver, with MaxStreams being 1.

Finally, it eliminates the trace buffer in the collector component exporter, preventing the core agent from buffering GiBs of traces under load.

All of these changes reduce trace drops while preventing uncontrolled memory growth.

Motivation

Previously, the OTLP Receiver in the Trace Agent dropped traces when the processor channel was full. This means that the receiver was dropping traces unnecessarily, and a better strategy is to block on the send. This will cause backpressure up through the otlp pipeline.

By default, a gRPC server will allow practically unlimited concurrent RPC requests, spawning a goroutine for each. The routine will read and deserialize the payload before calling the handler, which is now blocking.

This means that our memory usage is not reasonably bounded, since we could be holding hundreds of payloads in memory waiting to be processed. Limiting the number of concurrent RPC requests is required.

Finally, the backpressure goes to the core agent collector component. Here we need to remove the trace buffer to prevent GiBs of trace payloads from being buffered when it feels the backpressure from the Trace Agent.

Additional Notes

Possible Drawbacks / Trade-offs

Eliminating the trace buffer in the collector component could in theory result in higher trace loss in certain bursty scenarios. In practice, we don't see such scenarios and so this is a fair trade-off.

Describe how to test/QA your changes

We will use the new OTel load testing environment to exercise this change.

We should compare:

throughput (are traces being dropped)
memory usage (is memory usage better or worse)
See @knusbaum for details about more specifics regarding infrastructure.

This commit causes the Trace Agent OTLP Receiver to not drop traces when
the payload channel is full.

This commit also limits the number of simultaneous RPC requests,
forwarding the backpressure from the pipeline to the client, and limiting
our memory to O(MaxConnections * MaxStreams * MaxPayloadSize) in the
receiver, with MaxStreams being 1.

This should improve the trace dropping situation without exploding memory
as badly as having a large channel.

By default, a gRPC server will allow practically unlimited concurrent RPC
requests, spawning a goroutine for each. The routine will read and
deserialize the payload before calling the handler.

This means that our memory usage is not reasonably bounded, since we
could be holding hundreds of payloads in memory waiting to be processed.
@pr-commenter
Copy link

pr-commenter bot commented Feb 22, 2024

Bloop Bleep... Dogbot Here

Regression Detector Results

Run ID: c0508a00-2993-4501-bd7c-688aaba42bf2
Baseline: a82a8f9
Comparison: 31698d2
Total CPUs: 7

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

Experiments with missing or malformed data

  • basic_py_check

Usually, this warning means that there is no usable optimization goal data for that experiment, which could be a result of misconfiguration.

No significant changes in experiment optimization goals

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.

Experiments ignored for regressions

Regressions in experiments with settings containing erratic: true are ignored.

perf experiment goal Δ mean % Δ mean % CI
file_to_blackhole % cpu utilization -1.98 [-8.47, +4.52]

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI
otel_to_otel_logs ingress throughput +1.38 [+0.76, +2.00]
process_agent_real_time_mode memory utilization +0.33 [+0.29, +0.37]
uds_dogstatsd_to_api_cpu % cpu utilization +0.27 [-1.19, +1.72]
idle memory utilization +0.07 [+0.04, +0.10]
tcp_syslog_to_blackhole ingress throughput +0.06 [+0.00, +0.12]
file_tree memory utilization +0.03 [-0.06, +0.12]
trace_agent_json ingress throughput +0.02 [-0.02, +0.06]
process_agent_standard_check memory utilization +0.02 [-0.02, +0.06]
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.00, +0.00]
trace_agent_msgpack ingress throughput +0.00 [-0.00, +0.00]
uds_dogstatsd_to_api ingress throughput +0.00 [-0.00, +0.00]
process_agent_standard_check_with_stats memory utilization -0.40 [-0.43, -0.37]
file_to_blackhole % cpu utilization -1.98 [-8.47, +4.52]

Explanation

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

@knusbaum knusbaum marked this pull request as ready for review February 23, 2024 17:54
@knusbaum knusbaum requested a review from a team as a code owner February 23, 2024 17:54
@knusbaum
Copy link
Contributor Author

Re: regression detector,
This is a false positive, as we're touching nothing remotely related to UDS or dogstatsd.

@knusbaum knusbaum requested a review from a team as a code owner February 23, 2024 19:01
@knusbaum knusbaum modified the milestones: 7.53.0, 7.52.0 Feb 23, 2024
@knusbaum knusbaum added team/agent-apm trace-agent team/opentelemetry OpenTelemetry team labels Feb 23, 2024
Copy link
Contributor

@hestonhoffman hestonhoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small edit for consistency

@dineshg13
Copy link
Member

/merge

@dd-devflow
Copy link

dd-devflow bot commented Feb 25, 2024

🚂 MergeQueue

Pull request added to the queue.

This build is going to start soon! (estimated merge in less than 49m)

Use /merge -c to cancel this operation!

@dineshg13 dineshg13 modified the milestones: 7.53.0, 7.52.0 Feb 25, 2024
@dd-devflow
Copy link

dd-devflow bot commented Feb 25, 2024

❌ MergeQueue

This PR is rejected because it was updated

If you need support, contact us on Slack #ci-interfaces with those details!

@dineshg13 dineshg13 removed the request for review from liustanley February 25, 2024 23:53
@dineshg13
Copy link
Member

/merge

@dd-devflow
Copy link

dd-devflow bot commented Feb 26, 2024

🚂 MergeQueue

Pull request added to the queue.

This build is going to start soon! (estimated merge in less than 49m)

Use /merge -c to cancel this operation!

@dd-mergequeue dd-mergequeue bot merged commit a396d12 into main Feb 26, 2024
159 checks passed
@dd-mergequeue dd-mergequeue bot deleted the knusbaum/simple-otl-recv-plus-collectorconfig branch February 26, 2024 01:33
@github-actions github-actions bot modified the milestones: 7.52.0, 7.53.0 Feb 26, 2024
@knusbaum knusbaum added the backport/7.52.x automatically create a backport PR to 7.52.x label Feb 26, 2024
agent-platform-auto-pr bot pushed a commit that referenced this pull request Feb 26, 2024
…#23085)

pkg/trace/api: limit simultaneous otlp requests, do not drop payloads

Co-authored-by: dineshg13 <[email protected]>
(cherry picked from commit a396d12)
dd-mergequeue bot pushed a commit that referenced this pull request Feb 27, 2024
…#23085) (#23151)

[Backport 7.52.x] pkg/trace/api: limit simultaneous otlp requests, do not drop payloads

Co-authored-by: knusbaum <[email protected]>
knusbaum added a commit that referenced this pull request Feb 28, 2024
…#23085)

pkg/trace/api: limit simultaneous otlp requests, do not drop payloads

Co-authored-by: dineshg13 <[email protected]>
codeboten pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Mar 1, 2024
Updates all datadog dependencies to the psuedo version from the
[otel/backport](https://github.com/DataDog/datadog-agent/tree/otel/backport)
branch.

Removes [blocking channel
changes](DataDog/datadog-agent#23085) and
associated changelog.
XinRanZhAWS pushed a commit to XinRanZhAWS/opentelemetry-collector-contrib that referenced this pull request Mar 13, 2024
Updates all datadog dependencies to the psuedo version from the
[otel/backport](https://github.com/DataDog/datadog-agent/tree/otel/backport)
branch.

Removes [blocking channel
changes](DataDog/datadog-agent#23085) and
associated changelog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/7.52.x automatically create a backport PR to 7.52.x team/agent-apm trace-agent team/opentelemetry OpenTelemetry team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants