Load balancing Shuffle workers in Docker Swarm with HAProxy

Swarm's routing mesh can concentrate Shuffle worker traffic on a few tasks. Placing HAProxy in front of the worker tasks and pointing Orborus at it gives you control over how executions are spread across nodes.

On this page

Load balancing Shuffle workers in Docker Swarm with HAProxy: when a routing mesh is not enough

Put HAProxy in front of the Shuffle worker tasks when Swarm's routing mesh sends too much traffic to some workers and not enough to others. HAProxy gives you explicit control over which worker task receives each request, so you can balance load across servers instead of accepting whatever distribution the ingress layer produces. The routing mesh is a reasonable default, but it does not know how busy each worker is, and that gap is what teams running several servers tend to hit first.

Shuffle splits its runtime into three roles. The backend is the Go API on port 5001 that stores workflow state in OpenSearch. Orborus polls the backend for jobs and starts a worker for each workflow execution, and the worker starts the app containers that do the actual work. Shuffle's architecture docs describe a distributed Docker Swarm deployment, and the configuration docs recommend more than one Orborus node so workflows keep running if one fails. Teams need this load balancing layer once several Orborus nodes and worker tasks share a Swarm and one or two servers consistently run hot. Before adding HAProxy, confirm in your own environment which server each worker task lands on and whether the imbalance follows the routing mesh or your placement constraints.

The decision to make is whether HAProxy is worth the extra service to operate. Ask your team to confirm the current Shuffle version and the Swarm networking mode used for the worker service, because the setup depends on both. Plan who owns the HAProxy configuration, how health checks are defined for worker tasks, and how the gateway in front of the Swarm is exposed. The Shuffle architecture docs are the next read for the distributed layout.

Production-style Swarm layout with a gateway, HAProxy and worker tasks

The diagram starts at clients reaching the gateway on the external side of the trust boundary, then enters the internal Swarm overlay network where HAProxy spreads traffic across worker tasks on several Swarm nodes. Orborus nodes sit beside the workers, polling the Go backend on port 5001 for jobs, and the workers start app containers for each execution. The OpenSearch store holds the execution records. Check that the backend and OpenSearch are reachable only from inside the overlay, and that only the gateway is published outside it.

Gateway, HAProxy, Orborus and worker tasks split by the Swarm trust boundary.

Which load balancing layout fits which Swarm situation

Swarm's routing mesh publishes a service port on every node and forwards each connection to a task of that service, chosen by Swarm rather than by load. This layout fits a small Swarm with a few workers, similar hosts, and workflows whose apps are short and uniform. Nothing extra runs, so there is no balancer to patch or certify. The trade-off is that the mesh does not weigh current worker load, so long-running executions can pile up on some tasks while others sit idle.

  • Configuration: Orborus keeps the address it already uses for the worker service, and no change to its settings is needed for routing.
  • Visibility: You see load only through host metrics and Shuffle execution state, so overloaded workers are found after queues grow.
  • Failure handling: Swarm reschedules failed tasks, but in-flight executions on a lost task still need recovery steps.
  • Maintenance: Little recurring work beyond Swarm and Shuffle upgrades.

Before you rely on this layout, confirm with a load test that your slowest workflows do not concentrate on one host.

Setting up HAProxy in front of Shuffle worker tasks

This sequence places HAProxy between Orborus and the Shuffle worker tasks in a Swarm stack, so workflow executions spread across the workers more evenly. Each step closes with a check you can run before moving on.

  1. Deploy backend, Orborus and worker services

    The platform team, or the partner doing the build, deploys the Shuffle backend, Orborus and worker services as one Swarm stack from a stack file with docker stack deploy. Each service joins an overlay network that the HAProxy service will also join, so worker task addresses can be reached without exposing them through the routing mesh. Confirm that the stack file sets the networks and replica counts you intend. Check: docker service ls shows every service running at its expected replica count before you continue.

  2. Publish worker task addresses on a shared network

    Confirm that the worker tasks sit on the overlay network HAProxy joins and that the worker port described in the architecture docs is reachable between them. Swarm's embedded DNS resolves the name tasks.<worker-service> to one address per running task, and that list is what HAProxy will balance across. Check: from inside the HAProxy container, a DNS lookup of the worker task name returns one address for each worker task, and the count matches the output of docker service ps.

  3. Write the HAProxy configuration file

    Create haproxy.cfg with a resolvers section that points at Docker's embedded DNS, and a backend section that uses a server-template line to discover every worker task. Set a balance directive that matches your traffic pattern, such as roundrobin or leastconn, and add option httpchk with the health endpoint the worker exposes. Confirm that health path and port in the configuration docs before you rely on it. Check: running haproxy -c -f haproxy.cfg inside the container reports a valid configuration with no errors.

  4. Deploy HAProxy and confirm worker health

    Deploy HAProxy as a Swarm service on the shared network, mount haproxy.cfg into the container, and publish only the frontend port that Orborus will call. Enable the stats listener in the configuration and restrict it to operator networks, because it exposes server state. Check: the stats page lists every worker task as UP, and any task that is stopped or failing its health check shows DOWN until it recovers.

  5. Point Orborus at the HAProxy address

    Before editing anything, look up the Orborus setting that controls where it sends worker traffic in the configuration docs and confirm its exact name. Change that setting so Orborus targets the HAProxy service name and frontend port, and remove any direct reference to the worker service. Apply the change with docker service update --force on the Orborus service so it reloads. Check: Orborus logs show no connection errors after restart, and a test workflow execution starts and completes.

  6. Verify distribution with logs and metrics

    Run a small set of test workflow executions, then compare how many each worker task handled. Use the per-server session counts on the HAProxy stats page and the output of docker service logs for the worker service, along with task-level metrics if your monitoring collects them. If one task takes most of the load, check its health state and the balance algorithm before changing anything else. Check: the execution counts across worker tasks are broadly even for the test set, and the results are recorded in your runbook.

Security and operational considerations for the load balancer layer

Putting HAProxy in front of Shuffle worker tasks adds a component that sees worker traffic, reads Swarm state and can take the runtime down if misconfigured. The cards below cover the access, transport, network, secrets, change control and monitoring decisions to settle before the layout goes into production.

Limit Docker socket and manager access

Swarm management actions run through manager nodes and the Docker socket, and anything that can reach either can alter services, networks and secrets. Keep manager access to a named administrator group, avoid mounting the Docker socket into containers that do not need it, and confirm which accounts can run docker service update on the Shuffle stack. Review who can change the HAProxy service and its configuration, since that is the path by which traffic is redirected.

Shuffle architecture docs

Encrypt client traffic to HAProxy

Workflow triggers, webhooks and analyst sessions reach the Shuffle backend through the balancer, so the connection from clients to HAProxy should use TLS with certificates your team issues and renews. Decide where TLS terminates, whether HAProxy re-encrypts to the backend tasks, and how certificate renewal reloads the balancer without dropping active executions. Confirm this against the TLS guidance in the configuration docs for your Shuffle version.

Shuffle configuration docs

Restrict networks that reach worker tasks

Worker tasks should accept connections only from the balancer and the Orborus nodes that need them, not from every host on the overlay or the wider LAN. Place the HAProxy service and the worker service on a dedicated overlay network, and publish nothing from workers directly. Check the published ports on each service with docker service inspect after every deployment, because a stray published port exposes the worker outside the intended path.

Keep the encryption modifier identical everywhere

Shuffle encrypts saved app credentials and API keys in OpenSearch using the SHUFFLE_ENCRYPTION_MODIFIER secret. Every backend and Orborus node in the Swarm must see the same value, and it must be stored in a secret store you back up. Losing or changing it breaks all saved app authentications, so treat rotation as a planned migration rather than a configuration edit. Record where the value is kept and who can restore it before the balancer goes live.

Shuffle configuration docs

Control HAProxy configuration changes

A single change to backend addresses, health check paths or timeouts can route every workflow execution to the wrong tasks. Keep the haproxy.cfg file in version control, require review for changes, and validate it with haproxy -c -f before reloading. Test each change in a non-production stack that mirrors the worker count, and keep the previous configuration available for a fast rollback.

Monitor balancer and worker health

HAProxy exposes per-backend and per-server status, queue depth and error counts, and these show whether a worker task has dropped out of rotation or is queuing requests. Forward HAProxy logs to the same platform as Shuffle backend and Orborus logs, and alert on backends with no healthy servers and on sustained queuing. Agree which dashboard the on-call team checks first, and confirm the stats endpoint is restricted to administrators.

Questions buyers ask about Swarm load balancing for Shuffle

What does a Swarm and HAProxy load balancing project cost, and what drives the price?

The price follows from the written scope, and DeployOpen does not publish a price list. The main cost components are the design of the Swarm layout and gateway, the HAProxy configuration and health checks, the change to Orborus settings, and the validation under load. Costs rise with the number of worker nodes, the number of network zones, the amount of existing Swarm automation to reconcile, and how much of the work your team wants to pair on. Ask for a quote that separates one-time build work from any recurring support or upgrade retainer, and ask who runs the tests and who signs off on the results.

How long does validating a Swarm and HAProxy setup for Shuffle take?

No duration is fixed in this page's research, so treat any timeline as something to agree in the written scope. Validation length depends on how many worker tasks sit behind HAProxy, how many workflows you need to test at once, whether you have a staging Swarm that mirrors production, and how quickly your network and secrets teams approve access. Teams that already run Swarm with a gateway usually move faster than teams building the first Swarm cluster. Ask the provider to list each validation step, the load scenarios it covers, and the evidence you receive at the end.

What does our internal team need to provide for this work?

The work needs access to the Swarm manager and worker nodes, the ability to create overlay networks and services, and a place to store the HAProxy configuration and any TLS material. Network teams must confirm which ports Orborus and HAProxy can reach and which internal tools each worker must call. Secrets owners must agree how the SHUFFLE_ENCRYPTION_MODIFIER value is stored and rotated, because changing it breaks saved app authentications. Name one owner for each of these areas before the scope is signed so that approvals do not stall the build.

Can our own engineers build and run this Swarm and HAProxy setup?

Yes, a capable platform team can build it, provided it understands Docker Swarm networking, HAProxy health checks, and how Orborus picks up work from the Shuffle backend. The Shuffle architecture documentation describes Orborus polling the backend for jobs and starting a worker for each workflow execution, which is the behavior the load balancer must respect. The harder parts are testing under realistic concurrency and keeping the configuration correct through node failures and upgrades. Consider an in-house build if you have spare capacity and a test environment. Consider a partner if you need the work done on a fixed schedule or want an independent review of the result.

How does Shuffle's app run licensing interact with scaling workers?

Shuffle prices licensing on app runs, which are actions that actually execute in a workflow. Triggers and skipped actions are not counted, and users, apps and workflows are unlimited. Adding worker tasks behind HAProxy does not change how many app runs you perform, so it does not by itself change the licensing metric. However, more capacity usually means more workflows execute, which means more app runs, so plan for the volume your playbooks will generate. Since version 2.1.1, the limits between the open-source and enterprise editions are enforced, so confirm your edition and its limits before you scale. The Shuffle pricing article explains the metric in full.

What goes wrong when Swarm load balancing is set up incorrectly?

The most common failure is uneven load, where Swarm's routing mesh sends too many workflows to a few workers while others sit idle. Other failures include HAProxy sending traffic to tasks that are restarting, Orborus connecting to a worker address it cannot reach from its own network, and a single gateway becoming the point of failure. Each of these shows up as delayed or stuck executions rather than a clear error. Ask the provider to include failure tests such as stopping a worker task and a gateway node, and to show you the health check results and the logs you would check first.

Which parts of this work should we ask a provider to put in writing?

Ask for a written scope that names the Swarm layout, the gateway design, the HAProxy configuration, the Orborus changes, the load tests and the failure tests. Also ask for the deliverables, such as the configuration files, a runbook for node loss and an evidence pack showing test results. Confirm who owns the code and configuration after handover and who supports the system afterward. Most engagements are fixed-scope, so the agreed deliverables and timelines should be set in writing before work begins.

Where to read the official Shuffle documentation first

Start with the Shuffle architecture document before you touch a Swarm stack. It describes the deployment architectures Shuffle documents, including distributed Docker Swarm, and explains how the backend, the frontend, the OpenSearch document database and Orborus fit together. Read it with one question in mind: which component receives the traffic you intend to balance, and which component only needs to reach it. Orborus polls the backend for jobs and starts a worker for each workflow execution, so the path from Orborus to the worker tasks is the path HAProxy will sit on. Confirm that path in the architecture document against your own Swarm service names before you write any configuration.

Then read the Shuffle configuration document, which carries the high availability recommendations: an OpenSearch cluster, optional Memcached for a shared cache, NFS for shared files when several backends run, and more than one Orborus node so workflows keep running if one fails. Those recommendations decide whether a load balancer is the right fix at all, or whether the first fix is a second runtime node. Check the configuration document for the settings your deployment depends on, including the encryption secret, which must be kept unchanged across every node you add. For release checks, use the Shuffle GitHub releases page to confirm the version you plan to run is current and to see which tag the docs recommend for stable use. Record the tag you pin, because a load balancer change should not coincide with an unplanned version change.

How DeployOpen scopes and delivers Shuffle load balancing work

DeployOpen plans, builds, tests and documents the HAProxy layer in front of Shuffle worker tasks inside your own Docker Swarm, with Orborus pointed at it and the gateway layout agreed up front. The work runs in infrastructure you control, and the written scope sets which nodes, services and checks are included.

How we scope

  • We review your current Swarm layout, Orborus setup and worker placement before agreeing what changes.
  • The written scope names the nodes, stacks, HAProxy config, gateway and tests included in the engagement.
  • We confirm the Shuffle version you run and the Docker tag policy you follow, so the build targets your release.

How we build

  • We deploy HAProxy in front of the worker tasks, with health checks and balancing settings set for your load.
  • We point Orborus at the HAProxy endpoint and verify that workflow executions are spread across workers.
  • We test failure cases such as a worker task restart or a node drain, and record what happens to running executions.

How we hand over

  • You receive the stack files, HAProxy configuration and Orborus settings as versioned files in your repository.
  • We provide a runbook covering verification steps, log locations, rollback and how to change balancing settings safely.
  • We walk your platform and operations team through the layout and the test results before the engagement closes.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer if you want us to keep the layout current.
  • We can retest the balancing layout after Shuffle upgrades, Swarm changes or new worker nodes are added.
  • Support scope and response arrangements are set in writing, and we confirm them with you before the work starts.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.