Skip to content

Architecture

Bizon Platform has three processes and one database:

ComponentRuns asRole
APIpython -m bizon_platform (FastAPI on port 8000)REST API under /api, the cron scheduler, Git sync of custom sources
Workerpython -m bizon_platform.workerClaims pending runs and executes them
UIReact app served by nginx (Vite in dev)Calls the API through /api
PostgresPostgres 16Pipelines, runs, saved connectors, and Bizon’s cursor backend
  • pipelines: name (unique), Bizon config, cron schedule, enabled flag, tags.
  • pipeline_runs: status, triggered_by (manual or schedule), timestamps, error, log file path, output file.
  • saved_connectors: reusable source and destination configs.

Pipeline and saved-connector configs are encrypted with Fernet using ENCRYPTION_KEY. Without a key, they are stored base64-encoded, which is not encryption.

pending ──▶ running ──▶ success
│ ├──────▶ failed
└───────────┴──────▶ cancelled
  1. A run is created as pending, either by POST /api/pipelines/{id}/run or by the scheduler. A pipeline can have only one pending or running run at a time.
  2. A worker claims the oldest pending run with SELECT ... FOR UPDATE SKIP LOCKED and marks it running. Several workers never pick the same run.
  3. The worker replaces the config’s engine block with a Postgres backend that points at the platform database. Only engine.syncCursorInDBEvery from your config is kept.
  4. The worker starts a Python subprocess that runs the pipeline with bizon-core. The subprocess inherits the worker’s environment variables.
  5. When the subprocess exits, the run becomes success or failed. A run that exits with code 0 is still marked failed if its logs contain a line at ERROR level.

Cancelling sets the status to cancelled. A running worker notices within a fraction of a second, sends SIGTERM, then SIGKILL after 5 seconds.

Each worker process runs one pipeline at a time. When it finds nothing to do, it waits WORKER_POLL_INTERVAL seconds before polling again.

The worker captures the subprocess’s stderr and writes it every 2 seconds to:

{STORAGE_LOCAL_PATH}/logs/{pipeline_id}/{run_id}.log

The path is saved on the run when it finishes, so GET /api/pipelines/runs/{run_id}/logs returns null while the run is still in progress.

For pipelines with the file destination, the first data file the run produces is copied to {STORAGE_LOCAL_PATH}/{run_id}/ and can be downloaded from the API. .json files are renamed .jsonl.

The API and the workers must share STORAGE_LOCAL_PATH and CUSTOM_SOURCES_DIR. Docker Compose and the Helm chart both mount shared volumes for this.

The scheduler is APScheduler running inside the API process. Every minute it checks the enabled pipelines that have a schedule and creates a pending run for each one that is due. See Scheduling.

Each API process runs its own scheduler. Run a single API replica, or two replicas can race to create the same scheduled run.

Add workers to run more pipelines in parallel:

Terminal window
docker compose --profile prod up -d --scale worker=4

On Kubernetes, set worker.replicaCount or enable worker.autoscaling. See Kubernetes.