Production Deployment Checklist
In shortCheck 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 read
- 18 sections
- Updated
- v1.0.0
- Markdown
Already done by the server in production
With MODE=production, the server does these for you. You do not configure them; the sections below cover what you still own.
- Validates
MODEat startup: a typo stops the server instead of running with development defaults. - Runs strict production checks (
STRICT_PRODUCTION_CHECKS, on by default): wildcardORIGINSorALLOWED_HOST, wildcard CORS with credentials and enabled docs paths are refused at boot, and short HMAC JWT secrets are rejected. - Turns off the
/docsand/redocspages unless you set their paths. - Replaces 5xx error text, including streamed error chunks, with a generic message. Raise
ClientInputErrorfor 422 messages that must reach the client. - Cancels a graph run after 300 seconds unless you set
runs.timeout. - Turns debug mode off.
- Pings every configured backend at boot and refuses to start while one is unreachable (see Startup check).
- Ships a locked-down image when you use
10xgraph build: non-root user, Gunicorn withTenxGraphUvicornWorker(one Uvicorn process with--k8s) and long graceful timeouts, health check on/ping. On SIGTERM/health/readyanswers 503 while open runs finish.
For why these matter, see the security model and scaling and reliability.
What you still own
- Configure auth. Nothing refuses
"auth": nullin production; the server starts open and every route except/pingaccepts any caller. Set"auth": "jwt"or a custom backend (section 2). - Strong secrets, explicit
ORIGINS, and secret storage (sections 2 and 3). - A shared, durable checkpointer passed to
compile(), plus Postgres and Redis operations and backups (section 5). - Rate limits, worker count and replica count for your traffic (sections 6 and 7).
- Proxy, media storage, monitoring and the verification steps at the end.
Defaults to keep
The framework and generated template already ship tuned performance and safety defaults. Keep them unless you have a measured reason to change one:
- Let 10xGraph build Postgres pools. Pass
postgres_dsntoPgCheckpointeranddsntoPgVectorStoreinstead of passing your ownpg_poolorpool. Pools built by 10xGraph skip asyncpg’sRESET ALLquery on release and apply connection and query timeouts. If you must share an existing pool, configure a no-opresetfunction (Performance tuning). - Size pools inside
max_connections. Total database connections follow(checkpointer pool + store pool) * WEB_CONCURRENCY * replicas(or* replicason Kubernetes--k8s, plus worker pools if used). Set explicitpool_config={"min_size": ..., "max_size": ...}so the total stays below Postgresmax_connectionswith headroom for migrations and admin tasks (Postgres and Redis sizing). - Use
PgCheckpointerand Redis for multi-worker deployments. Never shipInMemoryCheckpointerorSqliteCheckpointerin production or with more than one worker (Scaling and reliability). - Never weaken safety defaults to silence an error. Keep
STRICT_PRODUCTION_CHECKSenabled, explicitORIGINSandALLOWED_HOST,DOCS_PATH/REDOCS_PATHempty,fail_open: falseon rate limits,enforce_user_isolation=True,LOG_REDACT_SECRETS=true, andLOG_LEVEL=INFO(Security model). - Keep a context manager on every agent. Leave
MessageContextManager(or another context manager) wired so prompt size and latency stay bounded as threads grow (Context management). - Compile once at import time. Export
app = agent.compile(...)at module level ingraph/agent.py; never compile per request (Configure 10xgraph.json). - Leave parallel tool calls on. Tools run in parallel up to
runs.max_parallel_tool_calls(10 by default); disable or serialize only when tools depend on each other (Scaling and reliability). - Keep
recursion_limitat 25. Raise it only when the normal agent flow requires more steps, and document why (Configure agent).
1. Runtime mode and debug settings
The first critical step is disabling development features. Set these environment variables:
MODE=production
LOG_LEVEL=INFOMODE=production enforces stricter validation at startup: wildcard CORS origins combined with credentials fail the server boot, and HMAC JWT secrets shorter than 32 bytes are rejected. STRICT_PRODUCTION_CHECKS is on by default in production and also stops startup on a wildcard ORIGINS, a wildcard ALLOWED_HOST, or enabled DOCS_PATH and REDOCS_PATH. Set STRICT_PRODUCTION_CHECKS=false to start with warnings only. It also turns off the /docs and /redocs pages unless you set their paths explicitly. Debug mode follows MODE, so it is off in production.
2. Secrets and authentication
JWT configuration
If you use JWT authentication in 10xgraph.json:
{
"auth": "jwt"
}Set a strong secret key and algorithm:
JWT_SECRET_KEY=$(openssl rand -hex 32) # 64 hex chars = 32 bytes, production minimum
JWT_ALGORITHM=HS256JWT_ALGORITHM defaults to HS256. Without JWT_SECRET_KEY the server still starts, and every authenticated request answers 500 JWT_SETTINGS_NOT_CONFIGURED, so check it before you deploy. The server fails to boot if PyJWT is missing, or if JWT_ALGORITHM is none, empty or not one of HS256, HS384, HS512, RS256, RS384, RS512, ES256, ES384, ES512, PS256, PS384, PS512 or EdDSA. The auth value must be exactly "jwt".
The server rejects a token that has no user_id claim. To mint a test token:
# Example using PyJWT (install: pip install PyJWT)
python -c "
import jwt
import os
secret = os.environ['JWT_SECRET_KEY']
payload = {'user_id': 'user-123'}
token = jwt.encode(payload, secret, algorithm='HS256')
print(token)
"Custom authentication
If you use custom authentication, ensure your BaseAuth subclass is deployed with its dependencies. Start the server and confirm a request without credentials is rejected with 401.
3. CORS and security headers
ORIGINS=https://app.example.com,https://admin.example.com
ALLOWED_HOST=app.example.comWith MODE=production the server refuses a wildcard ORIGINS or ALLOWED_HOST at boot. Security headers are on by default. See CORS and security headers.
4. Authentication and authorization
With auth on, each user reaches only their own threads (reach own). Review every role with reach all; the server logs them at startup. See Authentication and roles.
5. Persistence topology
Thread history, state snapshots, and message logs must survive server restarts and be shared across instances.
PostgreSQL setup
Use PgCheckpointer in production (pip install "10xgraph[pg_checkpoint]"). In your graph module, instantiate the checkpointer:
from tenxgraph.storage.checkpointer import PgCheckpointer
my_checkpointer = PgCheckpointer(
postgres_dsn="postgresql://user:password@postgres.internal:5432/10xgraph",
redis_url="redis://redis.internal:6379/0",
)
app = state_graph.compile(checkpointer=my_checkpointer)The API server calls the checkpointer’s asetup() at boot to create the tables. If that fails it logs the error and retries on first use. Call setup() or asetup() yourself only if your code manages startup outside the server. Make sure the database user has CREATE permission. List the tables:
psql "postgresql://user:password@postgres.internal/10xgraph" -c "
SELECT table_name FROM information_schema.tables
WHERE table_schema = 'public'
ORDER BY table_name;
"Expected tables in the public schema (or the schema= you pass): threads, states, messages, tool_executions, schema_version. They have no name prefix, so use a dedicated database or schema if you share the instance.
/health/ready answers 503 while the database schema version is below what the code expects, so a pod started before its migration ran stays out of rotation.
Startup check
At boot the server calls aping() on the checkpointer (Postgres, the schema version and its Redis cache), on the store when one is bound, and on the API’s cache store. It retries with a short backoff for STARTUP_CHECK_TIMEOUT_SECONDS (30 by default), so containers started together can come up in any order. The checkpointer and the store are fatal: if one is still down, the server exits with a message naming each backend and its endpoint (no credentials). The cache store is fatal only when a fail-closed feature uses it: cache_store.token_revocation is on (with auth), or cache_store.rate_limit is on with fail_open set to false. Otherwise the server logs one WARNING that the cache store is unreachable and that locks and caps fall back to per process, and starts anyway. A broken connection string therefore fails the deploy instead of the first request, and the orchestrator restarts the container until the backends are up.
A leftover REDIS_URL never blocks boot: it only matters to a cache_store of type redis with no url.
STARTUP_CHECKS=false skips the check. It runs the same probes as /health/ready, with a different outcome: at startup an unreachable checkpointer or store stops the server, while at runtime /health/ready answers 503 so the load balancer stops sending traffic until the backend returns. See Ping and health.
Redis caching
Redis acts as a hot cache in front of Postgres. PgCheckpointer requires a Redis connection, but the durable data lives in Postgres. After a Redis connection failure, PgCheckpointer skips Redis for a short cool-down (redis_breaker_cooldown, 5 seconds by default, 0 disables it) and uses Postgres at once, so a Redis outage does not slow every run step.
If several deployments share one Redis, set REDIS_KEY_PREFIX for the API (run locks and caps, idempotency, token revocation, rate limiting) and redis_key_prefix on PgCheckpointer to the same value. They are two separate settings, and each prefixes only its own keys.
REDIS_URL=redis://redis.internal:6379/0One run per thread
The server runs one graph run per thread. With a Redis cache store the lock is shared by every replica; with the in-memory one it is per process. See One run per thread.
Warnings you may see
The server logs a WARNING at startup in production, or when WEB_CONCURRENCY is above 1, if the checkpointer is InMemoryCheckpointer or SqliteCheckpointer (threads live in one process) or if the cache store is in-memory (run locks, caps and rate limits count per process, and token revocations only reach the process that received them). compile() logs a WARNING when you give it no checkpointer and it falls back to in-memory, and a graph logs one WARNING per graph on its first run with no user_id. These are your call; use PgCheckpointer with Redis for more than one process.
6. Horizontal scaling and workers
Deploy at least two API instances behind a load balancer to survive instance failures. Each instance must point to the same Postgres and Redis.
Gunicorn + Uvicorn (ASGI server)
The Dockerfile from 10xgraph build already starts Gunicorn with Uvicorn workers. If you run the server yourself, use the same flags. The generated command uses the TenxGraphUvicornWorker class, a 600-second graceful timeout and a 660-second worker timeout so long agent runs are not killed mid-flight. The worker marks the app as draining on SIGTERM (readiness answers 503) and waits TENXGRAPH_GRACEFUL_SHUTDOWN_SECONDS (540 by default) for open responses. Plain uvicorn.workers.UvicornWorker also works but skips the draining flag and the final “interrupted” chunk for open streams:
#!/bin/bash
set -e
export MODE=production
export REDIS_URL="redis://redis.internal:6379/0"
export JWT_SECRET_KEY=$JWT_SECRET_KEY # from environment
export ORIGINS="https://app.example.com"
gunicorn \
--workers 4 \
-k tenxgraph_api.src.app.uvicorn_worker.TenxGraphUvicornWorker \
-b 0.0.0.0:8000 \
--graceful-timeout 600 \
--timeout 660 \
tenxgraph_api.src.app.main:appSet the GRAPH_PATH environment variable to your 10xgraph.json if it is not in the working directory. Start with 2-4 workers per available CPU core. Monitor CPU and memory usage to tune.
Environment variable for workers
Gunicorn reads WEB_CONCURRENCY as the worker count if --workers is not specified. The generated Dockerfile sets it to 2:
WEB_CONCURRENCY=4Instance identity
If using Snowflake IDs for distributed, time-ordered thread identifiers, set unique node and worker IDs per instance:
SNOWFLAKE_NODE_ID=1 # datacenter id; increment per datacenter
SNOWFLAKE_WORKER_ID=1 # server instance id; increment per serverIn a second instance:
SNOWFLAKE_NODE_ID=1
SNOWFLAKE_WORKER_ID=27. Rate limiting
Add a cache_store.rate_limit block and use a Redis cache store so all replicas share the counters. /ping and /health/ready are never limited. See Rate limiting.
8. Proxy buffering and request handling
When running behind a reverse proxy (nginx, HAProxy, AWS ALB), ensure it forwards headers correctly:
# Example nginx configuration
proxy_pass http://10xgraph_backend;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
# Allow large request bodies for file uploads
client_max_body_size 50m;
# Buffer size for streaming responses
proxy_buffering off;For per-IP rate limits behind a proxy, set trusted_proxy_headers and trusted_proxy_hops; see Behind a reverse proxy.
9. Media storage and file uploads
Configure where uploaded files are stored:
MEDIA_STORAGE_TYPE=local
MEDIA_STORAGE_PATH=/data/uploads
MEDIA_MAX_SIZE_MB=25
MEDIA_ALLOWED_CONTENT_TYPES=image/*,application/pdf # empty (default) allows any typeFor cloud storage:
MEDIA_STORAGE_TYPE=cloud
MEDIA_CLOUD_PROVIDER=aws
MEDIA_CLOUD_BUCKET=my-bucket
MEDIA_CLOUD_REGION=us-east-1
MEDIA_CLOUD_PREFIX=10xgraph-mediaSee Storage backends.
10. Database backups
Postgres holds every thread, message and state snapshot. See Backup and restore.
11. Observability and monitoring
Logging
Set LOG_LEVEL=INFO and LOG_FORMAT=json in production, turn on the audit key (see Audit log), and ship stdout to retained storage you control; 10xGraph does not keep logs. The control mapping shows which audit controls this covers. The server generates a request ID per request and returns it in the X-Request-ID response header; log it on the client side to correlate with server logs.
Sentry error tracking
If using Sentry for error monitoring:
SENTRY_DSN=https://key@sentry.example.com/project
SENTRY_TRACES_SAMPLE_RATE=0.1OpenTelemetry tracing
For distributed tracing across your infrastructure:
OTEL_ENABLED=true
OTEL_SERVICE_NAME=10xgraph-api
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318Set the endpoint. With MODE=production and no endpoint, the server does not print spans to the console (they could carry request URLs and, at OTEL_LEVEL=full, the default, message content; OTEL_LEVEL drives only the legacy OTEL_ENABLED path, the observability block uses observability.level); it exports nothing and logs a warning at startup.
Traces and event publishers
Traces at the full level (the default; use standard or spans to send less) and the Redis, RabbitMQ and Kafka publishers carry message and tool content, and spans carry the user id. 10xGraph never forces TLS on these connections; it is your call:
- We recommend TLS in production whenever you can (
rediss://,amqps://, Kafkasecurity_protocol="SSL"or"SASL_SSL", anhttps://OTLP endpoint), and always on a network you do not control. - A broker or collector reachable only inside a network you secure yourself (a private subnet or VPC, or a service mesh that already encrypts traffic) can run without it.
- To keep real user ids out of traces, JSON logs and Sentry, set
"observability": {"user_id_mode": "hash"}(or"mask") in10xgraph.json. The audit log keeps the real id. - Leave
LOG_REDACT_SECRETSattrueandLOG_LEVELatINFOor above. The server warns at boot whenLOG_REDACT_SECRETS=falsein production.
See What is in your traces and events.
Verification checklist
Before opening the API to production traffic, run these tests:
1. Authentication works
curl -X POST http://127.0.0.1:8000/v1/graph/invoke \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": [{"type": "text", "text": "test"}]}]}'
# Should succeed with a valid token, fail with 401 if token is missing2. Thread persistence survives restart
# First invoke. Omit thread_id: the server starts a new thread and returns its id
# in data.thread_id. Use that id below.
curl -X POST http://127.0.0.1:8000/v1/graph/invoke \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": [{"type": "text", "text": "Remember: my name is Alice"}]}]}'
# Verify it's stored (replace THREAD_ID with the returned id)
curl http://127.0.0.1:8000/v1/threads/THREAD_ID/messages
# Stop the API server and restart it
# Verify state persists
curl http://127.0.0.1:8000/v1/threads/THREAD_ID/messages
# Should still contain the previous message3. Rate limiting is active
Send more requests than the limit to GET /v1/me and expect 429. Do not use /ping: it is never rate limited.
4. Security headers are present
curl -si https://api.10xgraph.com/ping | grep -iE "strict-transport-security|x-frame-options|x-content-type"5. Docs paths are disabled
curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:8000/docs
# Should print 4046. Load balancer health checks work
curl http://127.0.0.1:8000/ping
# Should return 200 OK with no auth requiredCommon issues
| Symptom | Cause | Fix |
|---|---|---|
| “A JWT secret key is shorter than 32 bytes” at startup | HMAC secret too short in production mode | Generate a longer JWT_SECRET_KEY |
| A thread answers 404 | User does not own the thread | Check that the token carries the same user_id as the thread’s creator, and the role’s reach |
| Thread state disappears after restart | Using InMemoryCheckpointer |
Switch to PgCheckpointer with Postgres DSN |
| One worker sees state, another does not | Workers are not sharing the same backend | Point all instances at the same Postgres and Redis |
| CORS requests are blocked | ORIGINS does not include the client domain |
Add the domain to ORIGINS. A public API can set ORIGINS=* with CORS_ALLOW_CREDENTIALS=false and STRICT_PRODUCTION_CHECKS=false |
409 thread is busy on a thread |
Another run is still active, and the 30 s wait ran out | Wait for the run to end, use on_busy: "cancel", or use one thread per conversation |
Server exits at boot with Refusing to start: ... backend(s) unreachable |
A configured Postgres, store, or (with cache_store.token_revocation or a fail-closed cache_store.rate_limit) cache store did not answer within STARTUP_CHECK_TIMEOUT_SECONDS |
Fix the URL or start the backend. STARTUP_CHECKS=false skips the check |
| Rate limiting not working | No cache_store.rate_limit block, or Redis is down (with fail_open true, requests pass) |
Verify cache_store.type is redis, its url or REDIS_URL, and Redis connectivity |
Related pages
Frequently asked questions
- What is the minimum checklist for production?
- Set MODE=production, use explicit ORIGINS, configure Postgres+Redis for persistence, enable rate limiting, and run at least two API instances.
- Can I use in-memory checkpointing in production?
- No. InMemoryCheckpointer loses all state on restart and cannot be shared across instances. Use PgCheckpointer for all production deployments.
- Do I have to use Redis?
- PgCheckpointer requires a Redis connection (redis_url, a redis_pool or a redis instance) in addition to Postgres; Redis is its cache and Postgres is the durable store. The API itself uses Redis as its cache store (run locks and caps, idempotency, token revocation, rate-limit counters) when `cache_store.type` is `redis`; without it those live in each process.