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 runs | GIL-serialized for pandas-heavy work | true multi-core across runs |
| Parallelism within one run | full (polars is multi-core) | same |
| Cancelling a run | cooperative and precise | instant 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_SECONDS | the run is abandoned but its thread finishes, so the CPU stays busy | the worker is recycled and the CPU comes back once this is the last active run |
| A run crashes or runs out of memory | can take down the whole server | only the worker dies |
| Plugin node-level hooks | fire | do not fire (graph-level hooks only) |
| Startup cost | none | each 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_RUNSabove 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.
# a shared box running scheduled jobs: isolation and a 5-minute cap per run
CIAREN_RUN_TIMEOUT_SECONDS=300 ciaren serve --execution-mode processThings to know
- Neither mode is a security boundary. A
processworker has the same privileges as the server. It isolates crashes, not code. For untrusted Python Transform scripts, seeCIAREN_PYTHON_TRANSFORM_STRICTand 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_RUNSand created once, so a change to that setting needs a restart to fully apply. - A timeout in
processmode 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 withprocesson unattended servers. - A permission revocation or plugin disable reaches already-running
processworkers 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:
| Variable | Effect |
|---|---|
CIAREN_SCHEDULER_ENABLED | Master switch. ciaren serve --no-scheduler does the same |
CIAREN_SCHEDULER_POLL_INTERVAL_SECONDS | Lower means more responsive and more wakeups |
CIAREN_SCHEDULER_MAX_CONCURRENT_RUNS | Cap on simultaneous scheduled runs |
CIAREN_SCHEDULER_MAX_CONSECUTIVE_FAILURES | Failures 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.