DogStatsD Buffer Limits and High-Cardinality Memory Pressure
0 reputation · 13 Aug 2020, 01:38 UTC
0 reputation · 13 Aug 2020, 01:38 UTC
The Datadog Agent implements a fixed-size buffer for DogStatsD metrics to prevent unbounded memory growth during throughput spikes. While the Agent is designed to drop packets when this buffer reaches capacity, the local aggregation map remains subject to memory pressure based on the volume of unique metric/tag combinations.
High-cardinality tags increase the size of the aggregation map held in memory between flush intervals. This creates a tension between the fixed UDP buffer limit, which prevents system crashes, and the dynamic memory requirements of the aggregation process.
When managing high-throughput environments, it is unclear how the Agent prioritizes memory allocation between the incoming packet buffer and the internal aggregation map during extreme cardinality events.
34775 reputation · 13 Aug 2020, 06:08 UTC
1. Does the Agent impose a hard memory cap on the aggregation map?
dogstatsd_cardinality_limit setting provides a hard limit on the number of unique series that can be kept between flushes.2. How does the flush interval influence peak memory?
dogstatsd_buffer_size) is fixed and independent of flush timing.dogstatsd_flush_interval (default 10 s) lets more series accumulate, so peak memory is roughly unique_series × entry_overhead plus the UDP buffer.net.core.rmem_max ≥ dogstatsd_buffer_size to avoid early kernel drops.datadog-agent version
Ensure it’s ≥ 7.40 (or 6.40 for older series).datadog-agent configcheck | grep -E "dogstatsd_(buffer_size|flush_interval|cardinality_limit)"
Note the current values.datadog-agent status | grep -A5 "dogstatsd"
# look for packets_dropped, metrics_by_context, series_countfor i in $(seq 1 200000); do
echo "test.metric:1|c|#tag:$i" | nc -u -w0 127.0.0.1 8125
done
Watch RSS in docker stats or ps -o rss and confirm that memory growth stops once the limit is hit.dogstatsd_flush_interval to lower peak memory for steady high‑cardinality traffic.dogstatsd_cardinality_limit if you’re hitting the limit but can tolerate dropping low‑volume series.To fine‑tune the recommendation, could you share your current dogstatsd_cardinality_limit value? If it’s set to the default or higher than your observed series count, you may want to lower it or adjust the flush interval.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.