redis pass to unix sockets working?
osevan opened this issue · 11 comments
It is possible to use unix socket in redis pass instead of localhost IP?
Like unix://path/redis.sock?
Thanks and
best regards.
yeah, it is working, I just tested it now.
mkdir /var/run/redis/ && chown -R redis:www-data /var/run/redis
then, in your /etc/redis/redis.conf, search for "unixsocketperm". modify "unixsocket" and "unixsocketperm" as following:
unixsocket /var/run/redis/redis.sock
unixsocketperm 777
then, service redis-server restart
.
then, in your nginx configuration, just pass to: unix://var/run/redis/redis.sock
@tzukav are you sure this is working? This does not seem to work for me at all.
connect() to unix:/... failed (11: Resource temporarily unavailable) while connecting to upstream
I have no trouble connecting to the UNIX socket with redis-cli -s unix:/...
It would be a very nice feature to use UNIX sockets with redis2-nginx-module.
@tzukav are you sure this is working? This does not seem to work for me at all.
connect() to unix:/... failed (11: Resource temporarily unavailable) while connecting to upstream
I have no trouble connecting to the UNIX socket with
redis-cli -s unix:/...
It would be a very nice feature to use UNIX sockets with redis2-nginx-module.
can i confirm this is still working.
"Resource temporarily unavailable" can be a user, permissions error. if the socket file exists, i'm pretty sure there is a user or permission error.
you can try by changing the nginx user to root temporarily, restart nginx and then see if it is working or not
Thanks for your answer @tzukav.
Sorry, I got it to work from the first time but was also doing some stress tests which caused the "Resource temporarily unavailable" error.
@woutd redis has max connection set by default to something like 10k as i remember. consider increasing ulimit too, the process may be auto killed if something like max open files is hit.
That is true, I already increased maxclients
and max number of open files (ulimit).
The "Resource temporarily unavailable" errors are temporary. Seems to be some "connection build up" limit I am hitting. After a great number of clients are connected everything seems to work.
But this is probably related with Redis, not the NGINX module.
(I was hitting the max number of ephemeral ports using IP, that is why I am looking at UNIX sockets.)
Edit: Increasing tcp-backlog
in Redis config resolved my issue.
@woutd yeah, i had same problem with backlog long time ago but in nginx, not redis. backlog is a always a problem in high traffic scenarios. forgot to tell you about it.
also, depending on what you are using redis for, you may want to take a look over https://nginx.org/en/docs/njs/reference.html#dict as a replace for redis non persistent data.