Skip to main content
In this tutorial, you’ll learn how to optimize your Docker Swarm services by controlling update parallelism, scaling replicated services, running tasks globally, and enforcing placement constraints. Whether you’re rolling out updates or targeting specific nodes, these patterns will help you deploy reliably at scale. We’ll cover:
  • Controlling update parallelism
  • Creating replicated services
  • Running services in global mode
  • Constraining services to specific nodes

1. Update Parallelism

By default, Swarm updates one task at a time. Adjusting the update parallelism speeds up rollouts or rollbacks across many tasks.
Example output:
To upgrade two tasks at a time, use --update-parallelism:
Re-inspect to confirm the change:
You’ll see UpdateConfig.Parallelism: 2 while the rollback parallelism remains unchanged.
Increasing --update-parallelism accelerates rollouts but may spike resource usage. Tune based on your cluster capacity.

2. Replicated Service

A replicated service ensures a fixed number of identical tasks across the swarm.
Progress output:
Verify service and mode:
Output:

3. Global Service

Global mode deploys exactly one task per active node. When nodes join or leave, tasks are added or removed automatically.
You’ll see a task scheduled on each node:
Confirm:

4. Placement Constraints

Placement constraints let you target services to nodes with specific labels.
  1. Label the node (replace <NODE_ID>):
  2. Verify the label:
  3. Create the constrained service:
All three tasks will run only on the node labeled env=dev.
If no nodes match the constraint, the service remains pending. Always verify labels before deployment.

Service Mode Comparison


That concludes this demo on Docker Swarm update parallelism, service modes, and placement constraints.

Watch Video