Skip to content

Execution Tuning

Ciaren runs dataframe work off the event loop so the API stays responsive. CIAREN_EXECUTION_MODE (also on the Settings page) chooses how that work is offloaded. For the pandas or polars choice, see Engines.

Thread or process

Stay on thread, the default, unless a symptom below pushes you off it. For one person running one flow at a time on polars, thread is simpler and just as fast. Polars compute is multithreaded Rust that releases the GIL, so a single run already uses every core in either mode.

thread (default)process
Parallelism between concurrent runsGIL-serialized for pandas-heavy worktrue multi-core across runs
Parallelism within one runfull (polars is multi-core)same
Cancelling a runcooperative and preciseinstant while the run is queued or loading its inputs. Once it executes in a worker, cancelling recycles the whole pool and is refused while other runs share it
RUN_TIMEOUT_SECONDSthe run is abandoned but its thread finishes, so the CPU stays busythe worker is recycled and the CPU comes back once this is the last active run
A run crashes or runs out of memorycan take down the whole serveronly the worker dies
Plugin node-level hooksfiredo not fire (graph-level hooks only)
Startup costnoneeach worker re-imports the app, so the first run is slower, especially on Windows

Switch to process when:

  • Ciaren is a long-lived shared server running scheduled jobs, where crash isolation and a timeout that reclaims CPU matter more than precise cancellation.
  • You raised SCHEDULER_MAX_CONCURRENT_RUNS above 1 and your flows are pandas-heavy. That is the one case where the GIL serializes work.

Stay on thread when you use Ciaren interactively on your own machine, or your flows run on polars.

bash
# a shared box running scheduled jobs: isolation and a 5-minute cap per run
CIAREN_RUN_TIMEOUT_SECONDS=300 ciaren serve --execution-mode process

Things to know

  • Neither mode is a security boundary. A process worker has the same privileges as the server. It isolates crashes, not code. For untrusted Python Transform scripts, see CIAREN_PYTHON_TRANSFORM_STRICT and the security docs.
  • Changing the mode on the Settings page is safe: it applies from the next run.
  • The process pool is sized from SCHEDULER_MAX_CONCURRENT_RUNS and created once, so a change to that setting needs a restart to fully apply.
  • A timeout in process mode frees the CPU as soon as no other run shares the pool. If others are still running, the recycle waits for them, so one hung run cannot abort its neighbors. Pair a timeout with process on unattended servers.
  • A permission revocation or plugin disable reaches already-running process workers on their next task. Each task carries the current plugin-state generation, and a worker re-syncs before it executes.

Scheduler

The background scheduler runs inside the API process. Scheduling describes its behavior. The settings:

VariableEffect
CIAREN_SCHEDULER_ENABLEDMaster switch. ciaren serve --no-scheduler does the same
CIAREN_SCHEDULER_POLL_INTERVAL_SECONDSLower means more responsive and more wakeups
CIAREN_SCHEDULER_MAX_CONCURRENT_RUNSCap on simultaneous scheduled runs
CIAREN_SCHEDULER_MAX_CONSECUTIVE_FAILURESFailures before a schedule disables itself

Run several API replicas with one scheduler

The scheduler is a single-process poller and does not coordinate across replicas. Start it on one replica and pass --no-scheduler to the rest.

See also