Graph and Cypher · Engineering

Background graph jobs and memory budgets

Long graph analytics without holding an HTTP request open: job states, concurrency, budgets, and atomic export.

A PageRank over a large graph is not a request you want to keep open behind a proxy timeout. It needs progress, cancellation, and a bounded memory budget. It also needs a result that can be consumed without blocking the database.

NonoDB provides background graph jobs for the same algorithms as graph_algorithm.

Starting a job

{"op":"start_graph_job","coll":"nodes","kind":"pagerank",
"direction":"out","max_nodes":100000,"max_edges":1000000,
"max_memory_bytes":268435456,"timeout_ms":10000,"iterations":20}

The response is:

{"job_id":"job-default-1","state":"queued"}

Jobs are database-scoped and accept the same options as synchronous algorithms.

States and progress

Operation Meaning
start_graph_job Validate and queue an algorithm
graph_job_status State, progress phase/done/total, timestamps, error
graph_job_result Completed result until export consumes it
cancel_graph_job Request cooperative cancellation
export_graph_job Atomically write a completed result into a collection

States are queued, running, cancelling, exporting, completed, failed, and cancelled.

Progress phases are scan_nodes, scan_edges, the algorithm name, and components. Workers check cancellation between every 1,024 items and each PageRank iteration. The pool is bounded to two concurrent jobs per database; additional starts return too_many_jobs.

Only the principal that started a job may read or cancel it.

Memory and time budgets

Algorithms are bounded by max_nodes, max_edges, max_memory_bytes, and timeout_ms. The memory budget covers node ids, adjacency, and the algorithm’s working maps, using conservative estimates. It is enforced during computation, not only when serializing the result.

Exceeding a budget fails explicitly. The job does not return a silently truncated graph.

The defaults are conservative: 100,000 nodes, 1,000,000 edges, 256 MiB, and a 10-second timeout in the example. The hard maximums are higher, but a small VM should not start with them.

Results are in memory

Jobs are in-memory metadata. They are cancelled and joined when the database runtime shuts down, and completed results are not persisted across restarts.

Use export_graph_job for durable output. It writes all result rows in one transaction, using deterministic _id values (<kind>:<node_id> or connected_components:<node_id>). A duplicate key or writer error aborts the whole transaction without partial documents.

Export consumes the in-memory result; graph_job_result reports not_found afterwards. Completed results are capped at 64 MiB each and 128 MiB total; older terminal jobs are evicted first. A result over the per-job cap fails with result_too_large.

Starting from the GUI or CLI

The same job API is available through the CLI and the Graph tab in the embedded GUI. The GUI shows job state and progress, and can export a completed result into a collection. The CLI is useful for scheduled analytics: start a job, poll status, export, and keep the result as normal documents with deterministic ids.

That workflow keeps the database as the source of truth and avoids a separate analytics database for one-off graph questions.

Why not just a long request?

A synchronous algorithm holds an HTTP connection and a read transaction. A proxy timeout, a client disconnect, or a restart can leave the caller without a result and the server without a clean cancellation point.

A job has explicit states, progress, cancellation, and an export step. That is a better fit for analytics that take more than a few seconds.

Operational checklist

  • Start with conservative budgets; raise them deliberately.
  • Export important results; do not rely on in-memory jobs across restarts.
  • Monitor the two-job concurrency limit.
  • Cancel jobs before dropping a graph or collection.
  • Run large analytics on a replica if possible.
  • Use the benchmark to estimate memory before production.

What it is not

  • No durable job queue across restarts.
  • No distributed graph processing.
  • No arbitrary custom algorithms.
  • No automatic retry after a failed job.
  • No unbounded result storage.

It is a bounded analytics feature inside a small database, not a graph compute platform.

The graph guide and graph analytics benchmark cover the states, limits, and measured costs.

All engineering notes →Read the docs