ezmobius/redis-rb — Issue #160: too short default timeout value (0.005ms)
Author: olek
Created: 2011-12-02 20:30:28+00:00
State: open

Default value for timeout is 5 microseconds, and that is one very aggressive timeout.

Our 'redis-centric' apps were throwing unusual errors EAGAIN (Resource temporarily unavailable - Timeout reading from the socket) from time to time.

Problem was fairly easy to reproduce with apache benchmark (ab) hitting our sinatra app ten thousand times

After some research, I narrowed down the problem to the too short of the timeout (5 microsecond), and experimented with increased timeouts. At 50 microseconds, it was much less likely to happen, but still happened once or twice for every 100k requests. 100 microseconds seems to be the shortest possible timeout that does not cause any issues in our environment (Slicehost servers).

I think, that default value for timeout should be changed out to a safer, larger value of 100 microseconds. After all, 0.1ms is still a fairly short timeout. Larger value will provide even more safety margin (1ms, anybody?), but 0.1ms seems to be a bare minimum.