差異處
這裏顯示兩個版本的差異處。
Both sides previous revision 前次修改 下次修改 | 前次修改 | ||
java:web:jetty:opentoomanyfilesissueonlinux [2016/07/04 16:25] tony [Jetty - Open Too Many Files Issue on Linux] |
java:web:jetty:opentoomanyfilesissueonlinux [2023/06/25 09:48] (目前版本) |
||
---|---|---|---|
行 1: | 行 1: | ||
{{tag>jetty}} | {{tag>jetty}} | ||
- | ====== Jetty - Open Too Many Files Issue on Linux ====== | + | ====== Jetty - Too Many Open Files Issue on Linux ====== |
最近開始使用security audit tool測試我們軟體(搭Jetty9.0.7): | 最近開始使用security audit tool測試我們軟體(搭Jetty9.0.7): | ||
<code bash> | <code bash> | ||
nikto -h 192.168.0.1 -port 80 -root /MyApp -mutate 1 | nikto -h 192.168.0.1 -port 80 -root /MyApp -mutate 1 | ||
</code> | </code> | ||
- | 大漏洞沒發現,卻發現在Linux上會經不起大量請求而產生Open Too Many Files Exception。使用ps -p $pid會發現很可能是socket沒關閉造成的問題: | + | 大漏洞沒發現,卻發現在Linux上會經不起大量請求而產生Too many open files Exception: |
+ | <code> | ||
+ | java.io.IOException: Too many open files | ||
+ | at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method) | ||
+ | at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:422) | ||
+ | at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:250) | ||
+ | at org.eclipse.jetty.server.ServerConnector.accept(ServerConnector.java:321) | ||
+ | at org.eclipse.jetty.server.AbstractConnector$Acceptor.run(AbstractConnector.java:460) | ||
+ | at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:601) | ||
+ | at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:532) | ||
+ | at java.lang.Thread.run(Thread.java:745) | ||
+ | </code> | ||
+ | 使用lsof -p $pid會發現很可能是socket沒關閉造成的問題: | ||
<code bash> | <code bash> | ||
java 9403 root 250u unix 0xffff8802653b1180 0t0 30861424 socket | java 9403 root 250u unix 0xffff8802653b1180 0t0 30861424 socket | ||
行 17: | 行 29: | ||
java 9403 root 270u unix 0xffff8802653b1180 0t0 30861424 socket | java 9403 root 270u unix 0xffff8802653b1180 0t0 30861424 socket | ||
</code> | </code> | ||
- | 後來爬一下文,原因是Jetty例外處理沒做好而造成的,更新到9.3.8測試socket占用問題即消失。 | + | (在ulimit沒被設定太小的前提下)\\ |
+ | 後來爬一下文,原因是Jetty例外處理沒做好而造成的,更新到9.3.9-v20160517測試socket占用問題即消失。 | ||
===== Reference ===== | ===== Reference ===== | ||
* [[https://bugs.eclipse.org/bugs/show_bug.cgi?id=416971|Bug 416971 - Jetty Leaks Connections in Time Wait]] | * [[https://bugs.eclipse.org/bugs/show_bug.cgi?id=416971|Bug 416971 - Jetty Leaks Connections in Time Wait]] | ||
* [[http://stackoverflow.com/questions/22763024/too-many-open-files-when-using-jetty-9-on-linux-ubuntu|Too many open files when using jetty 9 on linux (ubuntu)]] | * [[http://stackoverflow.com/questions/22763024/too-many-open-files-when-using-jetty-9-on-linux-ubuntu|Too many open files when using jetty 9 on linux (ubuntu)]] | ||
+ | ====== ====== | ||
+ | ---- | ||
+ | \\ | ||
+ | ~~DISQUS~~ |