处理Too open many files

最近遇到的一个问题,其实Linux 下的Too open many files 问题很普遍,常用的解决办法 http://www.javaeye.com/topic/240389,我这里的情况还有些不一样,具体情况是,在项目中使用memcached作为缓存,同时使用xmemcached作为客户端包,程序中由于大量从网络机器中获取缓存数据,打开大量的IO,项目使用了5台机器负载均衡,唯独有一台机器报出以下异常,其他机器正常:

[2011-01-27 18:24:35] 415615 [resin-tcp-connection-*:10002-8] INFO impl.AbstractController  - Controller has been stopped.
[2011-01-27 18:24:35] java.io.IOException: Too many open files
[2011-01-27 18:24:35] 	at sun.nio.ch.EPollArrayWrapper.epollCreate(Native Method)
[2011-01-27 18:24:35] 	at sun.nio.ch.EPollArrayWrapper.(EPollArrayWrapper.java:68)
[2011-01-27 18:24:35] 	at sun.nio.ch.EPollSelectorImpl.(EPollSelectorImpl.java:52)
[2011-01-27 18:24:35] 	at sun.nio.ch.EPollSelectorProvider.openSelector(EPollSelectorProvider.java:18)
[2011-01-27 18:24:35] 	at java.nio.channels.Selector.open(Selector.java:209)
... ...

问题显然是处在epoll上,最后修改了一下系统参数:
echo “1024” > /proc/sys/fs/epoll/max_user_instances
echo “1306071” > /proc/sys/fs/epoll/max_user_max_user_watches

This entry was posted in Linux. Bookmark the permalink.