High-Availability Agents
Run many agent replicas on one key, with failover and platform-managed scaling
By default, every agent process needs its own unique key (single mode). Agents can instead run in shared mode, where many replica processes connect with the same key and act as one logical agent:
The platform load-balances job executions across replicas (least-loaded first).
Heartbeats and metrics are aggregated across replicas in the UI.
If a replica dies mid-execution, the platform automatically requeues the stalled execution on a surviving replica (failover).
There are two ways to run shared-mode agents: manually (you scale the replicas) or platform-managed (the platform provisions and scales them for you on Docker or Kubernetes).
Enabling Shared Mode
Shared mode is enabled on the platform server, not on the agent:
services:
sling-platform:
environment:
SLING_RUNNER_MODE: sharedThis is a server-level setting that applies to every agent created afterwards — existing agents keep their current mode. The platform is authoritative at connect time, so replicas need only the agent key; the agent's own SLING_RUNNER_MODE does not decide the mode.
Manual Shared-Mode Replicas
Run any number of agent processes with the same key. Setting SLING_RUNNER_MODE=shared on the agent is optional (the platform decides), but harmless:
The same works with docker compose up --scale sling-agent=3 or several docker run invocations sharing one key.
All replicas of a shared key must run a recent agent binary. Older binaries predate HA and subscribe to the broadcast subject without a queue group, so mixing them with new-style replicas on one key can deliver — and run — the same job twice. The platform rejects a session-less (old) binary that tries to join a key already held by a live session, and logs a warning when it sees one. Upgrade every replica before scaling out.
Each replica needs its own cache directory. The agent keeps a local cache under its data dir; point it at per-pod ephemeral storage (an emptyDir volume in Kubernetes, the container filesystem in Docker) — never a shared PersistentVolumeClaim across replicas. This applies to replicas you run yourself; platform-managed agents (Docker (Local) and Kubernetes) already give each replica its own ephemeral cache.
Concurrency Limits in Shared Mode
An agent's max executions is a pool-wide cap in shared mode: the platform compares it against the aggregate number of active executions across all replicas, not per replica. The default heuristic (cpu_count × 2) scales automatically, because the reported CPU count is summed across live replicas — adding a replica raises the pool's capacity without any configuration change.
Docker-Local Managed Agents
For single-host installs (the typical docker compose up deployment), the platform can provision agent replica containers directly on the local Docker daemon. Enable it on the platform container:
Once enabled, a Docker (Local) hosting option appears in the agent creation dialog. The platform creates the containers, reconciles the replica count every 30 seconds, scales down oldest-first, and removes the containers when the agent is deleted.
SLING_DOCKER_RUNNERS accepts a bare mode (unix-socket or tcp) or a JSON object. The network field is required when the master runs in a container, so replicas can reach it by container name. All fields except mode:
mode
(required)
unix-socket or tcp
host
unix:///var/run/docker.sock
Daemon address (tcp://host:2376 for tcp mode)
tls_verify / cert_path
(off)
TLS client certs for tcp mode
network
(empty)
Docker network the replicas join; required when the master is containerized
image
slingdata/sling:<platform version>
Agent image override
cpu
2
CPU limit per replica container
memory_mb
3072
Memory limit (MB) per replica container
master_url
(derived)
URL replicas use to reach the platform
nats_url
(derived)
ws:// NATS URL override
restart_policy
unless-stopped
Restart policy for replica containers
labels
(empty)
Extra container labels (JSON object)
Docker socket security: mounting /var/run/docker.sock into the platform container gives it root-equivalent access to the host. For security-sensitive deployments, use rootless Docker or put a proxy like tecnativa/docker-socket-proxy in front of the socket (allow only container/image endpoints) and point the platform at it with SLING_DOCKER_RUNNERS='{"mode": "tcp", "host": "tcp://docker-socket-proxy:2375"}'.
Kubernetes-Managed Agents (HA)
When the platform runs in (or can reach) a Kubernetes cluster, it can manage agent replicas as a Deployment (plus a Secret for the key, and an optional HorizontalPodAutoscaler).
Set up in this order. The platform tests the Kubernetes API at startup, so apply the RBAC before you restart it.
1. Apply the RBAC
The platform needs permissions in the runner namespace (deployments, secrets, pods, horizontalpodautoscalers). Save the manifest below as runner-rbac.yaml and apply it:
It creates the runner namespace, the service account, a Role and a RoleBinding.
The manifest puts the service account in namespace sling-platform. If your platform runs in a different namespace, change it in two places: the ServiceAccount metadata and the RoleBinding subject.
To confirm the permissions are correct:
2. Configure the platform
Set the environment variable and the service account on the platform pod. Both are necessary — with mode: incluster the pod authenticates as its service account, and the default one has no permissions.
Replica pods must be able to reach the platform. The platform gives them SLING_PLATFORM_HOST when it is not localhost. An external name such as https://sling.example.com often does not resolve inside the cluster. When that applies, set master_url and nats_url to the internal service DNS:
3. Restart the platform
The platform tests the Kubernetes API at startup. If it starts and stays up, the connection is good. If the API is unreachable or the RBAC is wrong, the pod stops with an error in its logs.
4. Create the agent
The configuration alone starts no pods. A Kubernetes hosting option now shows in the agent creation dialog, with:
Desired replicas — the platform reconciles the Deployment to this count every 30 seconds.
Autoscale (HPA) — optional; the platform creates an
autoscaling/v2HorizontalPodAutoscaler with your min/max replicas and target CPU %, and stops managing the replica count itself. Requires metrics-server in the cluster. Install it before you use this option.
Create an agent with Kubernetes hosting. The platform then creates the Deployment, the key Secret and the pods in the runner namespace. Each pod is named sling-agent-<short-agent-id>:
Agents created this way are always shared-mode, so SLING_RUNNER_MODE is not necessary for them. Each pod gets its own emptyDir cache at /home/sling — you do not configure storage.
When you delete the agent, the platform removes the Deployment, the HorizontalPodAutoscaler and the Secret.
SLING_K8S_RUNNERS accepts a bare mode (incluster or kubeconfig) or a JSON object. All fields except mode:
mode
(required)
incluster or kubeconfig
kubeconfig
$KUBECONFIG or ~/.kube/config
Kubeconfig path (kubeconfig mode)
namespace
sling-runners
Namespace for runner Deployments
image
slingdata/sling:<platform version>
Agent image override
resources.cpu_request / resources.cpu_limit
500m / 2000m
CPU per replica pod
resources.mem_request / resources.mem_limit
1Gi / 3Gi
Memory per replica pod
master_url
(derived)
URL replica pods use to reach the platform (defaults to the platform host or http://sling-platform.<ns>.svc.cluster.local:<port>)
nats_url
(derived)
ws:// NATS URL override
image_pull_secrets
(empty)
Image pull secret names (JSON array)
node_selector
(empty)
Pod nodeSelector (JSON object)
tolerations
(empty)
Pod tolerations (JSON array)
service_account
(empty)
Service account for the runner pods
Last updated
Was this helpful?