wooga / eredis

Erlang Redis client
MIT License
628 stars 279 forks source link

reuseaddr setting to true cased eaddrnotavail in SOCKET_OPTS #61

Open hellowenniu opened 10 years ago

hellowenniu commented 10 years ago

Hi,

The concurrent connections in my project was about 30,000. I could find CRASH: {connection_error,{connection_error,eaddrnotavail}} in a percentage of 0.1%. The reuseaddr is set to true and looks like it is the root cause. The client would try to reuse the same port in time_wait status, but encounters eaddrnotavail error. Please refer to http://stackoverflow.com/questions/17606503/redis-exception-raised-in-gen-server/26523211#26523211

After change the code to: -define(SOCKET_OPTS, [binary, {active, once}, {packet, raw}, {reuseaddr, false}]). There is no more eaddrnotavail error.

olgeni commented 8 years ago

Is eredis still alive?

knutin commented 8 years ago

@olgeni: Yes, I'd say so :) I remember a case where you'd want to enable reuseaddr. I think maybe it was in the unit tests. Are the tests still passing on your branch?

@hellowenniu: It makes sense to fix this issue, either by setting the setting to false or allow it to be configurable. Just out of curiosity, how many Redis instances do you have? And are you using MULTI? A single connection to each instance should give you very good performance if you're using the simple commands, so no MULTI or blocking commands.