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:Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
- 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.--update-parallelism:
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.3. Global Service
Global mode deploys exactly one task per active node. When nodes join or leave, tasks are added or removed automatically.4. Placement Constraints
Placement constraints let you target services to nodes with specific labels.-
Label the node (replace
<NODE_ID>): -
Verify the label:
-
Create the constrained service:
env=dev.
If no nodes match the constraint, the service remains pending. Always verify labels before deployment.
Service Mode Comparison
| Service Mode | Description | Example Flag |
|---|---|---|
| Replicated | Fixed number of tasks | --replicas 8 |
| Global | One task per active node | --mode global |
| UpdateConfig | Control rollout parallelism & order | --update-parallelism |