Skip to content

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

Datadog Engineering 15 min read Deep dive hardMaster

Scaling metrics queries for AI workloads with Distributed DataFusion

Datadog built Distributed DataFusion, which takes a single-node Apache DataFusion physical plan, inserts NetworkShuffleExec operators at repartition boundaries, and schedules the resulting stages across worker pools that stream Arrow RecordBatches between them. The query planner hands DataFusion a Substrait plan. A worked timeseries example (counting distinct model/agent groups per 60s bin) shows the single-node plan, the distributed plan, and further optimizations. One is a subset-satisfaction rule, contributed upstream, that removes a redundant repartition and its network shuffle when the existing partitioning key is a subset of the grouping key. Another cuts the cost of grouping on string tags. In a Criterion benchmark, distribution alone cut latency from ~420 ms on 4 cores to 188 ms on 16, and the combined optimizations reached 42.2 ms, about 2.5× better per core.

Assumes: SQL query planshash aggregation and repartitioningApache Arrow columnar formattimeseries metrics

Related posts

  • How we extended Apache DataFusion to execute one query across many machines

    Datadog Engineering hardMaster

    Datadog built Distributed DataFusion, an open source Rust framework that extends Apache DataFusion's physical execution model so a single interactive query can run across many machines while keeping latency roughly flat as data grows. It reuses DataFusion's partitioning model and adds stages, tasks and network nodes such as NetworkCoalesce and NetworkShuffle. With these it distributes sorts, hash-partitioned aggregations, partitioned and broadcast joins, unions and tree-reduce aggregations, all as streaming execution without intermediate materialization. Datadog chose to extend DataFusion over adopting ClickHouse, Spark, Ballista or Trino because it needed extensibility, low latency, and Arrow/Substrait integration. Some heavy production queries now run up to 10× faster at the same total cost, and the planner keeps small queries on one node to avoid network, serialization and coordination overhead.

  • Your agents don't care that you're a batch shop

    ClickHouse easyNovice

    Agent workloads turn one business question into tens of sequential, bursty queries, so even batch-oriented firms querying yesterday's data need engines that minimize compute-seconds per query. Using queueing arithmetic (throughput ≈ cores divided by core-seconds held), a desk of 50 agents running 200,000 queries a day needs 667 compute-hours at 12 s per query versus 22 hours at 0.4 s, a 30-fold gap that credit-metered and autoscaling warehouses turn into budget overruns. The recommended engine properties are columnar reads, data skipping, vectorized execution, incremental aggregates, workload isolation and per-role limits, with the lake kept as the system of record. Teams should trace agent and infrastructure spans with OpenTelemetry, count queries per agent task, and compare hold time rather than latency alone.

  • Introducing multi-stage distributed query execution in ClickHouse Cloud

    ClickHouse hardMaster

    ClickHouse Cloud adds multi-stage distributed query execution, splitting a query plan into stages connected by exchange operators (Gather, Shuffle, Broadcast, Scatter) so intermediate data can be repartitioned between nodes mid-query. Shuffling by join key means each worker builds only its share of the hash table instead of the full right side, and shuffling by GROUP BY key removes the single-coordinator final merge for high-cardinality aggregations. Exchanges stream blocks between workers over TCP by default, with a persisted mode writing to object storage for spilling and future fault recovery. Early TPC-H results show up to 3.4× speedups on join-heavy queries and 7.4× faster aggregation on 8 nodes versus 1.

  • How to Reliably Scale Your Data Platform for High Volumes

    Shopify Engineering mediumAdept

    Shopify's Data Platform Engineering team prepared Tier 1 and Tier 2 ingestion and query services for a forecast near-doubling of BFCM 2020 traffic with a five-step reliability process. The steps were to define each service's primary objective (a freshness SLO for the Longboat batch ingester, a latency SLO for Reportify), identify tunable knobs such as job frequency, overlap interval, GKE CPU/memory, BigTable node pools and ProxySQL pools, and constrain those knobs to simulate N-times load. Teams then validated that every alert was actionable with simple runbooks and decided where to scale or tune. The exercise led to cluster scale-ups and job and query tuning, and BFCM ran with a 150% throughput increase and only minor self-healing incidents.

  • How we scaled raw GROUP BY to 100 B+ rows in under a second

    ClickHouse mediumAdept

    ClickHouse Cloud's parallel replicas feature spreads a single GROUP BY query across every core of every node in a service, with no pre-aggregation or data reshuffling. In the benchmark, 100 billion rows were aggregated in 414 ms at about 1.45 TB/s, compared with 16.6 s on a single 89-core node. The speedup rests on ClickHouse's execution model. Each pipeline stream scans a non-overlapping set of part ranges and builds mergeable partial aggregation states in one of 30+ specialized hash table variants, so any core or node can process any subset of rows and the partial results merge correctly. The post also covers memory behaviour by aggregate function, the reproducible benchmark setup, and how runtime scales vertically (more cores per node) and horizontally (more nodes).

The quest for software engineering knowledge.

Look:
Layout: