celluloid / celluloid-io

UNMAINTAINED: See celluloid/celluloid#779 - Evented sockets for Celluloid actors
https://celluloid.io
MIT License
879 stars 93 forks source link

TCP Sockets and TIME_WAIT #94

Closed robertjpayne closed 10 years ago

robertjpayne commented 10 years ago

When attempting to run a lot of connections against a Celluloid::IO Powered TCP Server after 2^14 (16384) connections the server has to wait for x minutes until TIME_WAIT connections get freed up again.

This is particularly noticeable in something like Reel using the Hello World example and running ab -n 20000 -c 50 http://127.0.0.1:5000/ it will effectively die at approx 2^14 requests.

I'm only opening this issue to investigate and either provide a suitable workaround or a documentation patch so others attempting to benchmark or heavily use Celluloid::IO know about it.

robertjpayne commented 10 years ago

Solution is to use setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true) which allows the TCP server to reuse local addresses at the small risk of data coming through.

tarcieri commented 10 years ago

The joys of OS X. Yeah, this issue has plagued ab for quite some time :(