If you get the error “too many open files” , please check below steps :

The file-max is the maximum File Descriptors (FD). It is a kernel setting enforced at the system level. The ulimit is enforced at the user level. It should be configured to be less than file-max.

The default settings are  very low , for high performance servers it  should be increased. The default settings assume that the several user share the same system and limit is  sufficient.

To change the file descriptor setting, edit the kernel parameter file /etc/sysctl.conf. Add line fs.file-max=[new value] to it.

for eg.     # vi /etc/sysctl.conf    and enter       fs.file-max = 400000

To apply the changes :
#sysctl -p

To change the ulimit setting, edit the file /etc/security/limits.conf and set the hard and soft limits in it :
for eg.# vi /etc/security/limits.conf
* soft nofile 40000
* hard nofile 40000

After changed reboot the server.
# reboot

Now,test system settings using the below commands:

#ulimit -a

To check the current open file descriptor limit:
# more /proc/sys/fs/file-max

OR sysctl -a | grep fs.file-max

To find out how many file descriptors are currently being used:

# more /proc/sys/fs/file-nr

To find out how many files are currently open:

# lsof | wc -l