When many tests are run in parallel, Sauce Connect will become the aggregation point for lots of connections. This can easily exhaust the number of available TCP ports on the machine where Sauce Connect is running. If many tests will be run at once, we recommend that you increase the number of available ports, and make ports reusable on the machine running Sauce Connect. This article contains instructions on how to accomplish this on three platforms.
Without properly configuring the TCP ports on the machine that is running Sauce Connect, you might run into some of the these issues during test execution:
- Slower and longer execution of tests
- Possible timeout errors and failures in tests
- Degraded performance in the Sauce Connect tunnel that can lead to the tunnel shutting down mid-execution
- Degraded performance in the machine that is running Sauce Connect
Change these settings in the registry:
reg add 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' /v MaxUserPort /t REG_DWORD /d 65534
reg add 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' /v TcpTimedWaitDelay /t REG_DWORD /d 30
Check that the new values are in effect:
reg query 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'
You need to reboot the machine for the new settings to take effect. See http://msdn.microsoft.com/en-us/library/aa560610(v=bts.20).aspx for more information about these settings.
To make ports in the
TIME_WAIT state reusable, and thus avoid port exhaustion, enable these sysctls:
$ sudo sysctl -w net.ipv4.tcp_tw_reuse=1
You can also reduce the time sockets spend in the
$ sudo sysctl -w net.ipv4.tcp_fin_timeout=1
net.ipv4.tcp_fin_timeout = 15
You don't need to reboot the machine for the changes to take effect.
You can make these settings permanent via:
$ echo "net.ipv4.tcp_tw_reuse=1"|sudo tee -a /etc/sysctl.conf
See http://vincent.bernat.im/en/blog/2014-tcp-time-wait-state-linux.html and http://kaivanov.blogspot.de/2010/09/linux-tcp-tuning.html for more information on what these settings do.
Mac OS X
To make more ports available to Sauce Connect, use this command:
$ sudo sysctl -w net.inet.ip.portrange.first=16384
To reduce maximum segment lifetime for TCP:
$ sudo sysctl -w net.inet.tcp.msl=15000
See http://rolande.wordpress.com/2010/12/30/performance-tuning-the-network-stack-on-mac-osx-10-6/ for more information on what these settings do.