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
| Service | Image | Role | Port |
|---|---|---|---|
frontend | clouisle-frontend | Next.js standalone server | 3000 |
api | clouisle-backend | FastAPI API | 8000 |
worker | clouisle-backend | Celery default, agent, knowledge, workflow queues | None |
sandbox-worker | clouisle-sandbox-worker | Celery sandbox and dedicated queues, artifact uploads | None |
beat | clouisle-backend | Celery Beat scheduler, must run with a single replica | None |
db | PostgreSQL 17 + pg_search | Business, full-text retrieval, and audit data | 5432 |
redis | Redis 7 | Queues, cache, sessions | 6379 |
qdrant | Qdrant 1.18.3 | Vector index | 6333 |
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.
| Queue | Consumer | Task modules | Work it carries |
|---|---|---|---|
default | worker | app.tasks.usage, notification, audit_log, api_key, password_expiration, memory | Usage resets, notification delivery, audit log archiving, API key and password expiry checks |
agent | worker | app.tasks.agent | AgentRun execution (model calls and tool loop) |
knowledge | worker | app.tasks.knowledge_base | Document parsing, chunking, embedding, and indexing |
workflow | worker | app.tasks.workflow | Workflow runs |
sandbox + per-worker sandbox.worker.<hash> | sandbox-worker | app.tasks.sandbox, tasks.cleanup_expired_sandbox_sessions | Code 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=4orkubectl scale deployment workerscales all four queues together. To scale one queue independently, run an extra worker container subscribed to a single queue, for example-Q agentto grow AgentRun execution only.- The
sandboxqueue 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. beatalways 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_typeisfeishuorwechat) with statuspending,sending,sent,error,unavailable, orunknown. The admin Delivery Log (/deliveries) readsGET /api/v1/admin/deliveries, which never returns message text, provider resource keys, or credentials. - Beat reconciles the integration schedule: Beat runs
IntegrationScheduler, which reads eachIntegration'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
defaultqueue dispatches every 3 seconds. Batch slots (WECHAT_POLL_MAX_BATCHES, default8) and claims live in PostgreSQL; each batch claims up toWECHAT_POLL_BATCH_SIZEbindings (default64) and pollsWECHAT_POLL_CONCURRENCYof them concurrently (default16), 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 theagentqueue 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:
workerandsandbox-workersetUPLOAD_STORAGE_MODE=remoteand reach the API's authenticated file gateway withAPI_INTERNAL_BASE_URLandINTERNAL_API_TOKEN(Kubernetes reads it viaINTERNAL_API_TOKEN_FILE). Onlyapimounts 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_idandstorage_idon 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-localhostPathin 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/apiprefix toapi:8000. In Compose the frontend service additionally rewrites/api/*toBACKEND_INTERNAL_URLthrough Next.js rewrites. - Next.js server → API:
BACKEND_INTERNAL_URLjoined with the base path. The code default ishttp://localhost:8000; Compose injectshttp://api:8000; the single-file K8s manifest and the default Helmfrontendworkload 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.
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:
| Variable | Compose / K8s value | Purpose |
|---|---|---|
POSTGRES_SERVER | db / postgres | Database |
REDIS_HOST | redis | Cache and Celery broker/backend |
QDRANT_URL | http://qdrant:6333 | Vector store |
API_BASE_URL | http://api:8000 | Internal API address for server-side use |
API_INTERNAL_BASE_URL | http://api:8000 | Where workers reach the upload gateway (UPLOAD_STORAGE_MODE=remote) |
SANDBOX_ARTIFACT_UPLOAD_BASE_URL | http://api:8000 | Sandbox 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?