56: Increasing connections for Bittorrent

Everybody needs to use Bittorrent sometimes. (If you couldn't pay for something if you tried, or it was offered for free in the first place, it's not piracy. But that's a separate topic.) I relied on µTorrent for years before dodgy business deals made it an adware-infested dumpster fire. That sad turn of events led me to try Transmission, a longstanding Mac client with Apple-like simplicity. I set it loose on a very large, very popular torrent, and it immediately brought down my entire home network.

No matter what I did, Transmission would only run for a couple minutes at best. While it was working, it was nearly saturating my 50Mbps downstream, so I got the hint that it was somehow doing too much traffic for my network to handle. In fact, it was trying to make too many connections over a single socket. (This was never a problem with µTorrent, which must have been making, breaking, and organizing connections differently.)

I assumed that I would have to change a setting in my router's admin control panel to fix the issue. If the relevant settings weren't available, I'd have to consider installing third-party firmware (a mess) or replacing the router entirely (a thought I apparently have frequently). In fact, since it was outgoing connections that were causing the trouble, I only needed to change a setting on my iMac. The maximum connections parameter is controlled by the Unix networking stack at the heart of OS X. Opening a terminal window and typing sysctl kern.ipc.somaxconn=4096 (system control – kernel – IP control – socket maximum connections) allowed more than ten times the number of connections.

And by "system" they meant "every device on your network".

That wasn't a flawless solution to the problem; I also added another safeguard by limiting connections in Transmission's settings. One of the problems is that Transmission seems to be very slow to close connections. Transmission's preferences limit active connections, but setting a limit of 100 there might allow 500 or so total connections to accumulate as peers come and go. Setting it to the same number as somaxconn is still a recipe for having Transmission clobber your network. Of course, the optimal numbers for your setup may vary, but you should be able to arrive at a combination that works. Then nothing will stand between you and the 100% legal "home movies" you want to download.