Skip to content
GitHub

Self-hostOperate

Scaling

Web processes are stateless and scale on CPU; workers scale on the job queue. Before adding either, make sure the instance runs on Postgres and S3 with distributed limits — the requirements for more than one process.

Job parallelism is workers × concurrency:

Layout Workers Concurrency per worker
Single container 1 jobs.concurrency (default 2)
Compose --scale worker=N jobs.concurrency, or --concurrency in the worker command
Kubernetes worker.replicas, summed over worker.pools worker.concurrency, else jobs.concurrency

More workers help only while there is work they may start. The queue runs at most one job per analyzer and repository at a time, and analyzers that push or open merge requests run alone on their repository or team. Jobs of other analyzers of one repository run side by side. A worker hands a free slot to the oldest job its credential limits admit, so a long-waiting job is not starved by a stream of short ones.

Merge request reviews do not wait behind the queue: they are claimed before every other job, and every worker keeps jobs.prioritySlots (default 1) extra slots that only reviews take, so a review starts within the 5 s poll even when all regular slots are busy. Budget memory for concurrency + prioritySlots jobs per worker.

Watch max(holtkeeper_jobs_queued): queued jobs due now. A queue that stays high with idle workers points at limits or exclusive analyzers, not at too few workers; the job’s wait reason in the panel, or why_job in Chat, says which.

  • web.replicas (default 2) or web.hpa (CPU, 2–5 replicas by default).
  • Any web pod can take a webhook; it only enqueues jobs in the shared store.
  • Only one process runs the scheduler at a time, under a lease in the store (30 s TTL, renewed every 10 s). With scheduler.enabled the scheduler gets its own Deployment and web pods run web only.

Pools split workers by node class. Each pool is a Deployment with the worker fields plus its own:

values.yaml
worker:
pools:
- { name: small, replicas: 3, concurrency: 2, spread: true, claimDelay: 15s }
- { name: big, replicas: 1, concurrency: 4, nodeSelector: { kubernetes.io/hostname: big-node } }
  • claimDelay makes a pool take only jobs queued at least that long, so pools without a delay take new jobs first and this one gets the overflow. Keep it above the 5 s poll interval.
  • spread: true keeps a pool’s pods on different nodes, counting only the current ReplicaSet.
  • strategy sets the pool’s Deployment update strategy. A pool pinned to one node without room for a second pod needs { rollingUpdate: { maxSurge: 0, maxUnavailable: 1 } }: the default surge pod would wait for the CPU the old pod holds.
  • Pools do not combine with KEDA.

Outside Kubernetes, --claim-delay (or HOLTKEEPER_CLAIM_DELAY) does the same per process.

Write tasks have a pool of their own, write, which only write workers serve; see Kubernetes › Write workers.

values.yaml
keda:
enabled: true
serverAddress: http://prometheus-operated.monitoring.svc:9090
threshold: '2' # queued jobs per worker replica
minReplicaCount: 1
maxReplicaCount: 10

A ScaledObject scales the worker Deployment on max(holtkeeper_jobs_queued) from Prometheus, which must scrape the web pods. With keda.scaledJob.enabled KEDA instead creates one Kubernetes Job per queued job (maxReplicaCount 20 by default), each pod running a single job and exiting — the strongest isolation the chart offers.

GitLab and AI tokens have rate and concurrency limits per credential. With limits: { distributed: true } the counters live in the store, so all workers share one token’s budget instead of each pod spending it in full. The starting configs turn it on with Postgres. Slots held by a process that dies return after 2 minutes without its heartbeat. Live usage per credential is in Settings › Integrations; holtkeeper_limiter_saturated shows a saturated token in Prometheus.

Every new worker pod starts with empty caches unless you share them. A ReadWriteMany PVC for worker.mirrorCache saves cloning every repository again; one for worker.miseCache saves installing tools again; the egress proxy’s download cache saves package downloads. See Kubernetes › Caches on volumes.

Scaling down sends SIGTERM: the worker stops claiming, running jobs get the drain timeout (worker.drainTimeout, default 120s in the chart) and are then requeued on another worker. Keep terminationGracePeriodSeconds above it (150 by default).