-
Notifications
You must be signed in to change notification settings - Fork 79
Description
Ruby's timeout has some serious issues. Rather than using Ruby's timeout for socket timeouts, it would be better to use setting on the socket itself or IO.select.
I was recently profiling a worker that we have that sends messages out to ActiveMQ. During the profiling, I found that nearly 70% of all the memory being allocated for this worker comes from Ruby's timeout. It is a very simple resque worker that gets a message and writes it to ActiveMQ using stomp. We maintain the same Stomp::Client for all of the messages that we send. I profiled this worker with 1000 messages. The total allocated memory was 1527649456 bytes. The total memory being allocated by timeout was 1052953152 bytes.
Example of using timeout on the socket - https://www.mikeperham.com/2009/03/15/socket-timeouts-in-ruby/
Example using IO.select - https://spin.atomicobject.com/2013/09/30/socket-connection-timeout-ruby/