skip to content
techgopal
rss
// FEATURE 005 · QUERY ENGINE · PART 2

When one machine beats a cluster for data work

When a single machine is enough for batch analytics, what it costs you, and when you do need a cluster. A practical test and how to measure.

// contents

Summary. A cluster pays for coordination: shipping plans, shuffling data over a network, recovering failed tasks. If your data fits on one machine's disk and a good part of it in memory, you can skip that bill, and a vectorised engine on one machine is often faster and always simpler to operate. It stops being true when the data or the throughput outgrows the machine, or when you need availability that one box cannot give. This post gives a test for which side you are on, and the method I use to measure it. Krishiv 0.2 is single-process by design; its measured results are on krishiv.ai/benchmarks.

Key facts

ItemValue
ClaimFor batch analytics over data that fits one machine, one process can be the right architecture
Krishiv stateRelease 0.2.0 runs embedded in your Python or Rust process. Distributed execution, streaming and Spark Connect are not in it
Memory behaviourHash aggregation, hash joins (with grace partitioning) and sorts are memory-bounded and spill to disk
Benchmark namingUnaudited results are described as "derived from TPC-H" and are never set beside audited results
Measured resultsMethod and figures are on krishiv.ai/benchmarks; this post gives none

What does a cluster actually cost?

Four costs, none of them about CPU.

  1. Shuffle. A join or group-by that needs rows with the same key together must move them between machines. Over a network that is much slower than a memory copy.
  2. Serialisation and scheduling. Plans and tasks are encoded, shipped, started and tracked. For short queries this overhead can exceed the work.
  3. Failure handling. Retrying tasks, keeping shuffle files, speculating on stragglers. Correct, necessary at scale, and complexity you carry even when nothing fails.
  4. Operations. Another system to size, upgrade, secure and debug.

On one machine the same query is a pipeline of vectorised operators over Arrow batches, with the "shuffle" being a hash table in memory.

How do I know if my data fits on one machine?

A rough test, in the order I apply it:

  1. Size on disk. Is the compressed Parquet (or whatever you read) under a few terabytes? Modern machines have that much fast local storage.
  2. Working set. What is the largest intermediate state a query holds: the build side of a join, the groups of an aggregation? That is what memory has to cover, and what spill handles when it does not.
  3. Rate. How many queries run at once, and how fresh must results be? One machine has a throughput ceiling.
  4. Failure. What happens if the machine dies mid-run? For a nightly batch you can rerun. For a service answering users all day, you may need a second machine, which is a different question from needing a cluster.

If steps 1 to 3 pass and step 4 is "rerun", one machine is a serious option.

What does spilling change?

It changes "does it fit in memory?" into "does it fit on disk?". Krishiv's aggregation, join and sort operators work against a memory pool; when a reservation cannot grow, the operator writes state to disk and carries on, checking for spill requests at every batch boundary. The query is slower than the in-memory case, but it finishes, and you set the limit. That is the property that makes a one-machine plan safe for a working set larger than RAM.

Measured results for Krishiv 0.2.0, with the method and the per-query figures, are on the benchmarks page. I do not repeat them here.

What does the measurement look like?

The method is the part to copy, and it is what the published benchmarks use:

  • Cold runs on one named class of machine, with CPU, memory and storage stated, but no hostnames.
  • The same data, the same queries, the results checked for equality against a second engine's output, and the checks reported with the timings.
  • More than one run per query, with the count stated. Two runs is thin: it is not a noise bound.
  • Resource cost next to the time: peak memory on the page; EXPLAIN ANALYZE reports memory and spilled bytes per operator for your own runs.
  • Benchmark names stay honest: "derived from TPC-H", with scale factor stated.

I have not run a cluster for this post, and I will not give a figure I have not measured.

When do you need a cluster?

  • The data does not fit on any single machine's storage, or the working set cannot spill fast enough.
  • Many users need interactive answers at once and a single box's throughput is the limit.
  • You need results to survive a machine failure without a rerun.
  • Your organisation already runs one, and the cost of an extra system is zero.

If your answer is "yes" to any of these, a cluster is the right tool. Krishiv's distributed path is not in 0.2; what exists is a scheduler that cuts a plan into stages and runs them as tasks in one process, which is groundwork, not a promise.

What does this mean for the rest of my stack?

The same instinct runs through all three projects: pick the smallest system that does the job honestly. For data that is one process. For a website it is one binary and PostgreSQL. For servers it is systemd and Caddy.

Series: 4. A control panel for my own servers · 5. This post · 1. Three projects, one person.

// subscribe