java - Too many open files even after setting kern.maxfiles -
i have set
kern.maxfiles=65536 kern.maxfilesperproc=65536
after this, put following command in .zshrc file
ulimit -n 30000
however, if try run netty based application eclipse, 10k sockets open , java io exception "too many open files" occurs. folowing stacktrace.
java.io.ioexception: many open files @ sun.nio.ch.serversocketchannelimpl.accept0(native method) @ sun.nio.ch.serversocketchannelimpl.accept(serversocketchannelimpl.java:422) @ sun.nio.ch.serversocketchannelimpl.accept(serversocketchannelimpl.java:250) @ io.netty.channel.socket.nio.nioserversocketchannel.doreadmessages(nioserversocketchannel.java:135) @ io.netty.channel.nio.abstractniomessagechannel$niomessageunsafe.read(abstractniomessagechannel.java:68) @ io.netty.channel.nio.nioeventloop.processselectedkey(nioeventloop.java:510) @ io.netty.channel.nio.nioeventloop.processselectedkeysoptimized(nioeventloop.java:467) @ io.netty.channel.nio.nioeventloop.processselectedkeys(nioeventloop.java:381) @ io.netty.channel.nio.nioeventloop.run(nioeventloop.java:353) @ io.netty.util.concurrent.singlethreadeventexecutor$5.run(singlethreadeventexecutor.java:834) @ io.netty.util.concurrent.defaultthreadfactory$defaultrunnabledecorator.run(defaultthreadfactory.java:137) @ java.lang.thread.run(thread.java:745)
i use following command check number of open files/sockets being used server , shows value more 10k when exception occurs.
lsof -p <pid> | wc -l
increase file descriptor value achieve. setting values "65536" invoking 30000 adding in shell
please change values reload bash, either su - in current session or open new terminal/session, restart application. must work
you can set ulimit of following link.
https://vasnlinux.wordpress.com/2015/05/01/linux-server-hardening/
Comments
Post a Comment