Deploy

In this sectionChoose Docker Compose or Kubernetes, see what 10xgraph build generates, what to set before going live, and how many replicas and workers to run.

  • 5 pages
  • About 32 min to read all

10xgraph build writes the deployment files for your project. You pick a target, fill in the production settings, and ship an image that runs the API in MODE=production. The server speaks plain HTTP, so a TLS proxy or load balancer always sits in front of it.

Choose a path

Item Docker Compose Kubernetes
Flag 10xgraph build --docker-compose 10xgraph build --k8s
Writes Dockerfile, .dockerignore, docker-compose.yml Dockerfile, .dockerignore, k8s.yaml
Good for One host, a small team, a first production run Several replicas, rolling deploys, autoscaling
Secrets .env file read by Compose (env_file) A Secret that the manifest reads
Default replicas One container, WEB_CONCURRENCY=2 Gunicorn workers 2 replicas, one Uvicorn process each
Guide Docker and Compose Kubernetes

With neither flag, build writes only the Dockerfile and .dockerignore. At a terminal it asks where you will deploy. Both targets accept --worker and --scheduler when your 10xgraph.json has a worker key with a broker other than memory.

What build generates

  • A Dockerfile with a non-root user (uid 10001), MODE=production, a /ping healthcheck, and Gunicorn with TenxGraphUvicornWorker (with --k8s, one Uvicorn process via python -m tenxgraph_api.src.app.serve).
  • A Gunicorn graceful timeout of 600 seconds and worker timeout of 660 seconds (the --k8s image uses a 540-second app deadline), because an agent run can last minutes. Compose and Kubernetes grace periods are set above that.
  • A read-only root filesystem and dropped capabilities. Only /tmp and /app/uploads are writable.
  • Optional worker and scheduler services built from the same image.

The image does not contain .env, keys or 10xgraph.json secrets. Your code and 10xgraph.json must be copied into it.

Set before you go live

Setting Why
auth in 10xgraph.json With auth: null the server starts open, also in production. Set "auth": "jwt" or a custom BaseAuth class.
JWT_SECRET_KEY 32 bytes or more, from a secret manager.
ORIGINS and ALLOWED_HOST A wildcard * stops startup in production.
cache_store.type: "redis" and REDIS_URL Without it, locks, caps, rate limits and revocations are per process.
A durable checkpointer such as PgCheckpointer InMemoryCheckpointer loses threads on restart and replicas do not share it.
Pinned dependencies and image tag The manifest uses the placeholder registry.example.com/<service>:1.0.0. Replace it.

Then run the production checklist and the pre-production tests.

Replicas and workers

  • API workers are stateless. Run more of them behind the load balancer, with Postgres for state and Redis for shared cache. Threads are not sticky.
  • Size on concurrent runs, not CPU alone. A run holds a connection open while it waits on model calls.
  • Set load balancer idle timeouts to at least 15 minutes, or long streams close mid-run.
  • Job workers (10xgraph worker) are a separate deployment, scaled on queue depth. Run exactly one 10xgraph scheduler.
  • Details and failure behaviour: Scaling and reliability.

Shutdown and ids

  • On SIGTERM the worker marks the app as draining, /health/ready answers 503, and open runs get up to 540 seconds to finish by default. See Graceful shutdown.
  • With several replicas, use ids that cannot collide. The default uuid4 generator is safe. For time-ordered numeric ids use Snowflake with a distinct node id per instance. See ID generators.

Pages in this section

All pages in Deploy

  1. Deploy with Docker and KubernetesGenerate a Dockerfile, docker-compose.yml and Kubernetes manifest with 10xgraph build, then ship them with a production environment checklist.5 min
  2. Deploy on KubernetesGenerate a Kubernetes Deployment and Service with 10xgraph build --k8s, with grace periods and probes tuned so long agent runs finish during rolling deploys.8 min
  3. Graceful shutdownShut a graph down cleanly with aclose() and install_shutdown_signals, what happens to cut-off runs, and how the API server drains on SIGTERM.5 min
  4. Configure ID generatorsControl the format of thread IDs and run IDs using built-in or custom generators to match your storage backend and observability requirements.2 min
  5. Production Deployment ChecklistCheck what the 10xGraph server does for you in production and what you still own: auth, secrets, ORIGINS, a durable checkpointer, rate limits and scaling.12 min