SSH Connection Calculator
Calculate concurrent SSH connections an Ansible run generates and the savings from connection multiplexing.
Inputs
Number of target hosts.
Concurrency limit set via --forks.
Tasks executed per host in the play.
Reuses a single SSH connection per host for the whole play instead of opening one per task.
Peak Concurrent SSH Connections
20connections
Total Connections This Run
150connections
Multiplexing Savings
96.7%
Connections Saved
4,350connections
Step by step
Concurrent connections: min(forks, hosts)
min(20, 150)
= 20 connections
Total connections without multiplexing
150 × 30 tasks
= 4500 connections
Total connections with multiplexing
150 × 1 (persisted per host)
= 150 connections
Savings from multiplexing
(4500 − 150) / 4500
= 96.7% (4350 connections saved)
How it works
Peak concurrent SSH load is capped at min(forks, hosts) — Ansible never opens more simultaneous connections than either your fork limit or your host count. Total connections over the whole run, however, depends heavily on whether SSH multiplexing (ControlPersist/ControlMaster) is enabled: without it, a naive per-task connection would need one SSH session per task per host; with it, one persistent connection per host serves every task in the play.
Formulas
With multiplexing
total_connections = hosts (one persistent connection per host)
- hosts
- Number of target hosts
Without multiplexing
total_connections = hosts × tasks_per_play
- hosts
- Number of target hosts
- tasks_per_play
- Tasks executed per host
Frequently Asked Questions
Is connection multiplexing on by default?
Modern Ansible enables pipelining and SSH ControlPersist-based multiplexing by default via the `ssh` connection plugin, but it can be disabled by configuration — always confirm `ansible.cfg`'s `[ssh_connection]` settings if you see unexpectedly high SSH load.
Why does peak concurrency matter separately from total connections?
Peak concurrency determines instantaneous load on the control node's file descriptors and the network/firewall's simultaneous-connection limits, while total connections over the run affects aggregate SSH daemon load on target hosts and any per-connection rate limiting.
Can too many concurrent SSH connections cause failures?
Yes — target hosts with a low `MaxStartups` or `MaxSessions` in sshd_config can reject connections under high fork counts, and firewalls/security groups with connection-rate limits can throttle or drop them.
How do I verify multiplexing is actually working?
Run with `-vvv` and look for `ControlPath` reuse in the SSH command output, or check `~/.ansible/cp/` for active control sockets during a run.