tcpproxy icon indicating copy to clipboard operation
tcpproxy copied to clipboard

accept4: too many open files

Open ncruces opened this issue 3 years ago • 0 comments

Hi, this is not a fault with the project, but it's something I hit while using this (and almost every alternative) and which surprised me, so maybe it'd be nice to add something about it to the documentation?

tcpproxy, correctly, does its best to take advantage of Go using the splice syscall to implement io.Copy between two net.TCPConn. This, however, leads to 6 fds being created for each proxied connection: the 2 net.TCPConn and 4 pipes (one in each direction for the each of the connections). This means you hit the (default?) soft ulimit of 1024 fds per process with just ~170 connections.

The "fix" is to raise the ulimit for the process, either using the syscall package, or systemd's LimitNOFILE directive.

ncruces avatar Jan 25 '21 11:01 ncruces