Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Datadog Engineering 12 min read Case study mediumAdept

How we scaled metrics aggregation by moving durable state into storage

Datadog's metrics aggregation service, which merges DDSketch distributions to reduce tag dimensions, went through three generations as volume grew roughly 10× each time. Static leader-follower partitions with local RocksDB doubled compute and needed manual partition splits. Dynamic Kafka assignment with incremental SSTable snapshots to blob storage and time-windowed lazy restore improved recovery and enabled autoscaling, but state recovery then became the bottleneck. The third generation makes streaming aggregation and deduplication best-effort. Both storage tiers reconcile partial aggregates, duplicates and late data during reads and compaction, so workers can restart at the live edge without restoring hours of state and can be provisioned for current traffic.

Related posts

  • Scaling down to speed up: How we improved efficiency of live process metrics by 100x

    Datadog Engineering mediumAdept

    Datadog cut real-time process and container metric traffic by about 100x by enabling 2-second live collection only on hosts whose processes a user is actually viewing (at most 50 per user), instead of on every host in the tenant. Sorting switched to the existing 10-second data, which removed the need to hold all live metrics in a single server's memory. Host subscriptions are published over Kafka at 1-second intervals to the intake service, which keeps a TTL-based in-memory cache of viewed hosts. Peak volume fell from 500,000 to 5,000 messages per second, the live data service shrank by about 98% (over 600 cores and 1 TiB of memory freed), and Agent CPU usage dropped about 2%.

  • Husky: Efficient compaction at Datadog scale

    Datadog Engineering hardMaster

    Husky, Datadog's observability event store layered over object storage, keeps query cost low by controlling fragment count and layout through streaming compaction. Writers flush small sorted fragments into time-bucketed tables. Compactors lazily run size-tiered k-way merges, waiting until a few dozen fragments are available, which cuts CPU and object-store API costs by an order of magnitude. Metadata is swapped atomically in FoundationDB. A custom columnar format with per-column headers and fixed-size row groups lets each compaction use one GET per input, saturate the CPU and run in bounded memory, and sort schemas let queries skip fragments using only their metadata.

  • Evolving the Backend Storage for Platform Metrics

    Heroku Engineering mediumAdept

    Heroku migrated the time-series store behind MetaaS, its internal metrics service, from self-managed Apache Cassandra to AWS DynamoDB without user-visible impact. MetaaS ingests a couple hundred thousand observations per second into Kafka and aggregates them with stream-processing jobs, writing tens of thousands of points per second to the database. The migration used parallel dual-writes from Kafka and GitHub Scientist-style shadow reads, ramped to 100% of traffic, to catch edge cases. TTL-based retention meant no data backfill was needed: they waited for old Cassandra data to expire, then incrementally cut reads over. p99 query latency dropped from a variable 20–80 ms to a steady 15 ms, and costs fell.

  • Achieving relentless Kafka reliability at scale with the Streaming Platform

    Datadog Engineering mediumAdept

    Datadog runs hundreds of Kafka clusters with millions of partitions and built the Streaming Platform, a control layer that decouples producers and consumers from specific clusters through "Streams" spanning clusters, AZs and Kubernetes environments. A custom coordinator, the Assigner, replaces Kafka's timeout-based group coordination with metric-driven, seconds-scale rebalancing and live failovers that create a new topic and drain the old one. Head-of-line blocking is removed with priority lanes, a dead-letter lane for poison pills, and multi-range offset tracking stored in commit metadata, which also carries ingestion timestamps to compute real-time time lag from __consumer_offsets. After zstd decompression bombs crashed consumers, the team built libstreaming, a Rust Kafka client with bindings for other languages, and rejected a gRPC proxy because of throughput and latency costs.

  • Husky: Exactly-once ingestion and multi-tenancy at scale

    Datadog Engineering hardMaster

    Husky, Datadog's columnar event store, achieves exactly-once ingestion and cost-efficient multi-tenancy by routing events deterministically to Kafka partition groups (shards), so deduplication only has to happen within a shard. Time-bounded, immutable Shard Placements are allocated per tenant by a Sharding Allocator that uses FoundationDB transactions to give every Shard Router node the same answer. An Autosharder resizes each tenant's shard count from byte-throughput metrics. Consistent hashing with wraparound and shard exclusions keeps placement churn minimal, and a balancer counters hotspots. Limiting how many tenants each writer handles also cuts the number of blob-storage files and compaction work.

The quest for software engineering knowledge.

Look:
Layout: