ClouisleClouisle

Deployment architecture

Understand Clouisle service topology, request routing, dependencies, and persisted data

Clouisle runs 5 application services using 3 images. clouisle-backend provides api, worker, and beat; clouisle-sandbox-worker provides sandbox-worker; clouisle-frontend provides the Next.js frontend.

Service topology

ServiceImageRolePort
frontendclouisle-frontendNext.js standalone server3000
apiclouisle-backendFastAPI API8000
workerclouisle-backendCelery default, agent, knowledge, workflow queuesNone
sandbox-workerclouisle-sandbox-workerCelery sandbox and dedicated queues, artifact uploadsNone
beatclouisle-backendCelery Beat scheduler, must run with a single replicaNone
dbPostgreSQL 17 + pg_searchBusiness, full-text retrieval, and audit data5432
redisRedis 7Queues, cache, sessions6379
qdrantQdrant 1.18.3Vector index6333

Celery queue layout

The clouisle-backend image starts api, worker, and beat through subcommands. Task-to-queue routing is declared statically in task_routes in backend/app/core/celery.py, and the consumed queue names are passed with -Q.

QueueConsumerTask modulesWork it carries
defaultworkerapp.tasks.usage, notification, audit_log, api_key, password_expiration, memoryUsage resets, notification delivery, audit log archiving, API key and password expiry checks
agentworkerapp.tasks.agentAgentRun execution (model calls and tool loop)
knowledgeworkerapp.tasks.knowledge_baseDocument parsing, chunking, embedding, and indexing
workflowworkerapp.tasks.workflowWorkflow runs
sandbox + per-worker sandbox.worker.<hash>sandbox-workerapp.tasks.sandbox, tasks.cleanup_expired_sandbox_sessionsCode sandbox execution and session cleanup; interactive session tasks only enter the dedicated queue of the worker that owns the session

The supplied Compose, Helm, and single-file manifests run the worker as python main.py worker -c 4 -Q default,agent,knowledge,workflow — one service consuming all four queues — and the sandbox worker as python main.py sandbox-worker -c <SANDBOX_WORKER_CONCURRENCY>, consuming sandbox plus its own sandbox.worker.<hash> queue.

Periodic tasks dispatched by Beat: sweep-lost-agent-runs every 2 minutes on the default queue (reclaims AgentRuns still marked in-flight after a worker crash and is the only producer of INTERRUPTED), and cleanup-expired-sandbox-sessions every 15 minutes on the sandbox queue. Tasks on the agent queue set no retries: model calls and tool execution have side effects, so a retry would execute them twice.

Scaling rules:

  • docker compose up -d --scale worker=4 or kubectl scale deployment worker scales all four queues together. To scale one queue independently, run an extra worker container subscribed to a single queue, for example -Q agent to grow AgentRun execution only.
  • The sandbox queue is its own service, so adding sandbox workers does not affect knowledge base or workflow processing; each instance must still use its own node-local disk and never share a volume.
  • beat always runs a single replica, see Service topology.

Messaging integrations and delivery

Feishu and WeChat iLink are two providers of the same Integration model. They add no separate service and no per-provider delivery tables.

  • One delivery queue: every outbound message and artifact is written to integration_deliveries (provider_type is feishu or wechat) with status pending, sending, sent, error, unavailable, or unknown. The admin Delivery Log (/deliveries) reads GET /api/v1/admin/deliveries, which never returns message text, provider resource keys, or credentials.
  • Beat reconciles the integration schedule: Beat runs IntegrationScheduler, which reads each Integration's enabled capabilities from PostgreSQL every 2 seconds and registers only the enabled periodic tasks — WeChat binding polling (3 s, default), WeChat Agent binding recovery (3 s, agent), WeChat knowledge receipt recovery (60 s, knowledge), Feishu Agent channel recovery (10 s, agent), and Feishu knowledge sync dispatch (60 s, knowledge). Toggling a capability therefore needs no Beat restart, but Beat must be restarted once after an upgrade, because an old Beat process keeps running the old scheduler.
  • WeChat polling runs in ordinary workers: the default queue dispatches every 3 seconds. Batch slots (WECHAT_POLL_MAX_BATCHES, default 8) and claims live in PostgreSQL; each batch claims up to WECHAT_POLL_BATCH_SIZE bindings (default 64) and polls WECHAT_POLL_CONCURRENCY of them concurrently (default 16), stops at 30 seconds, and its claim can be taken over after 90 seconds. It is a plain Celery task with no dedicated receiving process.
  • Who owns the Feishu long connection: with connection_mode=long_connection, only workers consuming the agent queue supervise one receiver child process from the worker parent; a Redis lease (15-second TTL, 2-second reconciliation) elects a single holder so messages are never received twice. The HTTP callback mode still works.
  • Workers never touch the uploads volume: worker and sandbox-worker set UPLOAD_STORAGE_MODE=remote and reach the API's authenticated file gateway with API_INTERNAL_BASE_URL and INTERNAL_API_TOKEN (Kubernetes reads it via INTERNAL_API_TOKEN_FILE). Only api mounts the uploads directory; with object storage configured, even that mount is unnecessary.

Sandbox sessions and checkpoints

Code execution runs in the separate sandbox-worker, which pins sessions to a worker:

  • Each sandbox worker derives a worker_id and storage_id on its retained disk (.worker-identity.json). Every execution, checkpoint save, and expiry cleanup for a session is delivered to that worker's dedicated queue, sandbox.worker.<sha256(worker_id)>.
  • The worker writes a checkpoint at the end of each round; a restarted process or reset session resumes from it, and a session may be recovered once by default (SANDBOX_SESSION_MAX_RESETS=1). Heartbeats are 5 seconds with a 20-second expiry, and recovery starts 30 seconds after a worker goes silent.
  • The workspace and checkpoints must therefore stay on that worker's persistent disk: a named volume (sandbox_data) in Compose, a node-local hostPath in Kubernetes. They are not shared storage, and sessions on a lost node or disk cannot be recovered on another node.

Request routing

An external reverse proxy or Ingress routes requests: /api/* to api:8000, everything else under / to frontend:3000. The frontend image does not include Nginx; deploy/nginx/default.conf is only an optional external example.

Keep the two hops separate:

  • Browser → API: the browser calls NEXT_PUBLIC_API_URL (frontend image build-time default /api/v1, i.e. a relative path), and the reverse proxy or Ingress forwards the /api prefix to api:8000. In Compose the frontend service additionally rewrites /api/* to BACKEND_INTERNAL_URL through Next.js rewrites.
  • Next.js server → API: BACKEND_INTERNAL_URL joined with the base path. The code default is http://localhost:8000; Compose injects http://api:8000; the single-file K8s manifest and the default Helm frontend workload carry no environment variables.

The backend mounts every router under API_V1_STR, default /api/v1: GET {API_V1_STR}/health and {API_V1_STR}/openapi.json move with it. If you change that value, update the proxy/Ingress path and the frontend build-time NEXT_PUBLIC_API_URL to the same /api/v1 prefix, or both browser and server-side calls will hit a path that does not exist.

Clouisle deployment architecture
Clouisle deployment architecture

Persisted data

Default Compose volumes: postgres_data, redis_data, qdrant_data, uploads_data, and sandbox_data. api alone owns uploads_data; multiple API replicas using local upload storage require ReadWriteMany, and with only ReadWriteOnce, keep a single API replica. Worker and Sandbox Worker mount no uploads volume and still scale independently. sandbox_data is mounted by one sandbox-worker only and must never be shared between replicas.

Site settings (Site Settings > Storage) can switch the upload backend to object storage (object_storage_*); uploads then no longer depend on a shared volume, so multiple replicas can run across nodes.

Internal addresses

Use service names inside containers, never localhost:

VariableCompose / K8s valuePurpose
POSTGRES_SERVERdb / postgresDatabase
REDIS_HOSTredisCache and Celery broker/backend
QDRANT_URLhttp://qdrant:6333Vector store
API_BASE_URLhttp://api:8000Internal API address for server-side use
API_INTERNAL_BASE_URLhttp://api:8000Where workers reach the upload gateway (UPLOAD_STORAGE_MODE=remote)
SANDBOX_ARTIFACT_UPLOAD_BASE_URLhttp://api:8000Sandbox worker artifact uploads

In Kubernetes, FRONTEND_URL is http://frontend:3000 (SSO redirect base) and clouisle-secret provides INTERNAL_API_TOKEN, which pods read through INTERNAL_API_TOKEN_FILE=/var/run/secrets/clouisle/internal-api-token. Worker and sandbox-worker mount no uploads volume; they go through this internal gateway instead.

How is this guide?

On this page