Skip to main content
This guide shows you how to add Redis caching (DATABASE_REDIS_URL) to an existing self-hosted OpenWork Helm deployment and optionally run multiple Den API replicas. Follow the stages in order: connect and verify Redis first, check pod resources and MySQL connection headroom second, and raise denApi.replicaCount last.

Before you start

You need:
  • Your complete, reviewed openwork-values.yaml, Helm release name, and Kubernetes namespace.
  • kubectl and helm access to the cluster, plus read-only SQL access to your MySQL server to check connection limits.
  • A Redis instance reachable from the OpenWork namespace with AUTH enabled, maxmemory-policy volatile-lru, and memory sized so evicted_keys stays 0 (512 MiB maxmemory is a practical starting point, monitor and adjust for your workload). Persistence (RDB or AOF) is optional because OpenWork treats Redis as a TTL-backed cache and short-lived authoring store. Prefer TLS (rediss://).
  • Cloud worker provisioning off (config.provisioner.mode: stub, the default) if you plan to run more than one Den API replica. If cloud worker provisioning is enabled, keep denApi.replicaCount: 1 unless your worker provider operations are idempotent or externally coordinated.
Capture a short baseline before making changes so you can compare before and after:
On MySQL, check the current connection limit and usage:

Step 1: Connect Redis (DATABASE_REDIS_URL)

Adding Redis enables Den API’s shared session, membership, feature-flag, and inventory-revision caches. Run this stage before increasing denApi.replicaCount.
  1. Supply DATABASE_REDIS_URL through your Secret.
    • If secret.create: false (secret.existingSecret, recommended for production): Add a key named literally DATABASE_REDIS_URL to your existing Kubernetes Secret in the release namespace. Because den-api loads the Secret through envFrom, keep the key name DATABASE_REDIS_URL rather than remapping it with secret.keys.databaseRedisUrl.
    • If secret.create: true: Set secret.values.databaseRedisUrl in openwork-values.yaml and keep secret.keys.databaseRedisUrl at its default DATABASE_REDIS_URL.
  2. Configure TLS or an explicit private-network opt-in.
    • Prefer rediss://:<password>@<redis-host>:6379. If Redis uses a private certificate authority, enable customCa with your CA bundle (see Certificate trust and proxies).
    • For a non-public, cluster-internal redis:// endpoint protected by a NetworkPolicy or service-mesh mTLS, set redis.allowInsecureInternal: true in openwork-values.yaml. Without this setting, Den API refuses to start on non-loopback redis:// URLs.
  3. Apply the change and restart Den API if you edited an external Secret.
    If secret.create: false, Helm does not detect edits inside an existing external Secret. Restart Den API so the pods pick up DATABASE_REDIS_URL:

Verify Step 1

  • Confirm den-api startup logs report "redis cache configured" with redis_cache: "enabled" (and "redis cache connected" once the first cache call runs), show zero openwork_cache_redis_error or openwork_cache_get_failed lines, and that the pod stays Ready.
  • On Redis (INFO stats), confirm keyspace_hits is rising and evicted_keys stays 0.
  • Re-run kubectl --namespace "$NAMESPACE" top pods and the MySQL Questions check to compare database query rate and CPU against your baseline before deciding whether to scale replicas.
Rollback: Remove DATABASE_REDIS_URL from your Secret (or clear secret.values.databaseRedisUrl), revert redis.allowInsecureInternal if added, and restart Den API. No database schema change is involved.

Step 2: Set pod resources and verify MySQL connection headroom

The Helm chart leaves resources: {} by default, which places pods in Kubernetes BestEffort QoS. Before running multiple API replicas, set explicit requests and limits and verify that MySQL has enough connection slots.
  1. Add provisional resource requests and limits to openwork-values.yaml. These values are starting envelopes to leave BestEffort QoS, not load-tested sizing guarantees. Measure and adjust for your cluster.
    Leave config.denApiNodeOptions: "" blank unless you need custom Node flags, so Node sizes its heap automatically from the container memory limit. If you set --max-old-space-size explicitly, keep it roughly 25% below denApi.resources.limits.memory (for example --max-old-space-size=1536 inside a 2Gi limit) to avoid OOMKills.
  2. Check MySQL max_connections before scaling. With default pool settings (config.database.pool), each pod opens its own mysql2 pool: up to 10 connections per den-api pod, and up to 20 connections per AI Gateway pod (10 primary plus 2 * 5 auxiliary pools; releases prior to configurable pool defaults open up to 30 per AI Gateway pod). Double those per-pod totals if DATABASE_READ_USERNAME and DATABASE_READ_PASSWORD are configured for read replicas against the same MySQL server. Default rolling updates temporarily surge by 25% rounded up (one extra pod per Deployment up to four replicas), and the pre-upgrade migration Job uses up to 10 connections:
    MySQL’s default max_connections (151) fits denApi=2, gateway=1 (~95 peak without read replicas; ~115 on earlier releases with 30-connection Gateway defaults), but becomes tight at denApi=3, gateway=2 (~125 peak; ~155 on earlier releases) and leaves little margin if you raise config.database.pool.connectionLimit. Raise MySQL max_connections to 300 or higher, and verify MySQL CPU and memory headroom, before scaling beyond two Den API replicas or one Gateway replica, or before raising pool limits in config.database.pool.

Step 3: Scale Den API replicas (optional)

Proceed only after Step 1 (Redis) and Step 2 (resources and MySQL headroom) are verified. Running denApi.replicaCount > 1 without Redis degrades caching and breaks cross-pod workflow authoring receipts.
  1. Set denApi.replicaCount (and optionally denWeb.replicaCount for web redundancy) in openwork-values.yaml:
  2. Render with helm template, verify the Deployment replica counts and resource blocks, and apply with helm upgrade --reset-values --values openwork-values.yaml --wait --timeout 15m.

Verify Step 3

  • Run kubectl --namespace "$NAMESPACE" get pods and confirm all den-api replicas are Ready and balanced under kubectl top pods.
  • On MySQL, confirm Max_used_connections stays safely below max_connections (target under 50%).
  • Verify end-to-end flows across replicas: sign in and sign out (confirming session revocation), open the dashboard and AI Gateway pages, run an MCP tool call from desktop, and test saving a workflow if enabled.
  • If you mount local desktop installers on den-api, use a shared read-only PVC across replicas (see Installer delivery).
Rollback: Set denApi.replicaCount: 1 in openwork-values.yaml and run helm upgrade --reset-values. No data is lost.

Reference

See the Helm chart reference for the complete secret, redis, database.pool, denApiNodeOptions, and worker-provisioning configuration options.