How to Configure Scaling
This guide shows how to add capacity to a Lemline deployment. For the reasoning behind it, see Understanding Scaling in Lemline.
When to Scale
Add capacity when:
broker lag or queue depth keeps growing
lemline_messaging_commands_activestays close to the configured concurrencystep processing time (
lemline_messaging_commands_processing_duration_seconds) grows with load
Add Runners
Runners are stateless. Start more of them with the same configuration:
Stopping a runner is safe: messages it did not acknowledge are delivered to another runner.
Try it on one machine
On the SQLite setup, two workers started from the same directory share the same files and the same work. Stop the setup worker, then start two workers with their own metrics ports, each in its own terminal in the setup directory (with the JAR, substitute java -jar lemline.jar for bin/lemline):
From a third terminal, register the first workflow and start it a dozen times:
Each instance completes once, and both worker terminals show Workflow completed with output lines: in one run, one worker completed 8 instances and the other 4. SQLite keeps everything on one host; to spread workers over several machines, use a shared database and broker.
With Kafka
Runners in the same consumer group share a topic's partitions, so a topic needs at least as many partitions as runners. Keep the same group id on every runner:
With RabbitMQ or PGMQ
Runners reading the same queue compete for its messages; no extra setting is needed.
Tune Concurrency per Runner
Each channel processes up to 64 messages in parallel. Raise the limit when steps mostly wait on remote calls, lower it when a runner runs short of memory:
Set the limit under the broker you use (lemline.messaging.<broker>.<channel>.consumer.concurrency). The broker-independent lemline.messaging.<channel>.consumer.concurrency only applies to in-memory messaging: with Kafka, RabbitMQ or PGMQ it is overwritten by the broker setting.
Tune Background Processing
Waits, retries, schedules, listeners and gateway starts are processed from the database by every runner. For a large backlog, process bigger batches or run more often:
See the outbox properties in the Runner Configuration Reference.
Split Work by Namespace
Give a workload its own runners by putting it in its own namespace and starting runners that serve only that namespace:
Runners without lemline.namespaces serve the default namespace only.
Scale the Gateway
Run several lemline gateway start processes behind a load balancer that supports gRPC (HTTP/2). They share the database and need no coordination.
Kubernetes
Run runners as a Deployment and scale its replicas. A CPU-based Horizontal Pod Autoscaler is a reasonable starting point:
With Kafka, keep maxReplicas at or below the number of partitions. Use /q/health/live and /q/health/ready on the metrics port as liveness and readiness probes.
Common Issues
Symptom | Likely cause | What to do |
|---|---|---|
New runners stay idle (Kafka) | More runners than partitions | Add partitions to the topics |
Runners receive messages they do not process ( | Runner not configured for the message's namespace | Fix |
Database CPU saturates as runners are added | Shared database is the bottleneck | Scale the database; reduce outbox batch frequency |