I am running varnish with nginx as proxy on ubuntu and I am getting (24: Too many open files) error every few days. Restarting nginx solves the problem. After researching about this error I found that the common solution is to increase worker_rlimit_nofile in nginx.conf. I feel like this is not a real solution since the limit I will set might reach as well.
Why nginx keeps these files (I believe these are the sockets) open? and what will a solution to my situation?
UPDATE:
I just noticed there are hundreds of varnish sockets open when I run lsof. I believe my issue is that these sockets don't get closed.