When do you actually need a cluster?

A TPC-H benchmark across Apache Spark, DuckDB, Polars and DataFusion — five single-machine configurations plus a real 2-worker Spark cluster, all reading identical Parquet.

On one machine, at what data size does a distributed engine (Spark) beat an in-process one (DuckDB / Polars / DataFusion) — and when is a cluster still the right call?

Headline

Total wall-clock over the 8-query subset at SF10 (docker, 8 vCPU, 16.6 GB RAM):

EngineTotal (s)× fastest
DuckDB 8.0 1.0×
DataFusion 9.8 1.2×
Polars 15.3 1.9×
Spark (default) 79.6 9.9×
Spark (tuned) 88.2 11.0×
Spark (2-worker cluster) 125.5 15.6×

Spark on defaults is 9.9× slower than DuckDB here — almost entirely fixed per-query overhead (query planning, task scheduling, JVM start-up, shuffle) that an in-process engine simply doesn't pay. On data this small it never gets the chance to amortise it.

Tuning Spark (shuffle-partition count, broadcast threshold, Kryo) made it 11% worse at SF10; the 2-worker cluster is 1.6× the local-mode time (network shuffle for no extra scale).

How each engine scales

total workload time vs scale factor, per engine
Total time for all 8 queries as the dataset grows. Watch whether the Spark lines converge toward the in-process engines.
total workload time per engine
Total workload time per engine at SF10 (sum of the 8 warm-median times).
total workload time per engine, smallest scale factor
The same at SF1.

Per query

per-query latency by engine
Warm-run median per query, log scale. Q1/Q6 are scans; Q5/Q9 are 6-table joins; Q18 aggregates then joins.
QueryDuckDBPolarsDataFusionSpark (default)Spark (tuned)Spark (2-worker cluster)
Q1 1.161 4.647 0.932 4.619 4.425 6.769
Q3 0.833 0.953 0.730 9.107 10.247 12.313
Q5 0.885 1.565 1.098 18.259 16.656 28.435
Q6 0.397 0.356 0.550 1.130 1.255 1.697
Q9 1.980 2.401 2.052 10.027 11.216 18.043
Q10 0.938 0.976 1.039 6.890 7.219 12.106
Q12 0.577 0.637 0.880 4.579 4.581 6.433
Q18 1.275 3.795 2.538 24.954 32.558 39.696

Does tuning Spark close the gap?

Not meaningfully — not at these sizes. Spark's default AQE already coalesces post-shuffle partitions; sizing shuffle parallelism by hand, raising the broadcast threshold and switching to Kryo made it 11% worse. It stays one to two orders of magnitude off the in-process engines either way. The knobs earn their keep on data large enough for the shuffle to dominate — past what a single machine holds — which is exactly where this benchmark stops.

spark default vs tuned per query
Spark on defaults vs the same Spark with shuffle-partition count sized to the data, a 16 MB broadcast threshold, Kryo, and larger scan splits. Each knob is in docs/methodology.md.

Memory

peak RSS per engine
Peak resident memory during the run (single-machine configs only — the cluster's executors live on the workers).

Reading this

The pattern almost every run shows: in-process engines dominate at the sizes a single modern machine can hold. Spark's architecture — a driver, a scheduler, serialized tasks, a JVM per executor — is built to survive node failure and scale horizontally. On one box, over data that fits in RAM, that machinery is pure overhead, and it shows up as a near-constant per-query tax.

Spark earns its keep when: the working set genuinely exceeds one machine's memory and can't be partitioned away; you need the fault tolerance for multi-hour jobs; or you're already invested in the ecosystem (Delta/Iceberg ACID, a shared catalog, streaming). The measured "you need a cluster" threshold has moved from ~100 GB a few years ago to several TB — this benchmark is one data point on where it sits today.

And a small standalone cluster is the wrong move on one host: this run's 2-worker cluster was slower than local mode, because you've added a network shuffle and RPC round-trips without adding any data that needed distributing.

Setup & method

Host: docker · Linux 6.18.33.2-microsoft-standard-WSL2 · 8 vCPU · 16.6 GB
Engines: DuckDB 1.5.5 · Polars 1.44.1 · DataFusion 54.0.0 · Spark (default) 3.5.3 · Spark (tuned) 3.5.3 · Spark (2-worker cluster) 3.5.3
Workload: TPC-H queries 1, 3, 5, 6, 9, 10, 12, 18 · scale factors 1, 10
Correctness: every engine's output is compared to DuckDB's, row-for-row within TPC-H tolerance — 96 checks passed.

Reproduce it

git clone https://github.com/aleksamilic-dev/tpch-engine-benchmark
cd tpch-engine-benchmark
docker compose build
docker compose run --rm bench python -m datagen.generate --sf 1

docker compose run --rm bench python -m bench --sf 1 --engines duckdb,polars,datafusion
docker compose run --rm bench python -m bench --sf 1 --engines spark
docker compose run --rm bench python -m bench --sf 1 --engines spark-tuned

# the 2-worker standalone cluster
docker compose up -d spark-master spark-worker-1 spark-worker-2
docker compose run --rm --use-aliases bench python -m bench --sf 1 --engines spark-cluster

docker compose run --rm bench python -m report.build_report

Your absolute numbers will differ by hardware; the ratios between engines are what travels.