简体   繁体   English

ElasticSearch消耗100%CPU

[英]ElasticSearch consumes 100% CPU

After some period of time (sometimes minutes, sometimes days), my app start consuming 100% CPU. 在一段时间(有时是几分钟,有时是几天)之后,我的应用开始消耗100%的CPU。 As I see from VisualVM, it's always happening at org.elasticsearch.common.netty.channel.socket.nio.NioClientSocketPipelineSink class. 从VisualVM中可以看到,它始终在org.elasticsearch.common.netty.channel.socket.nio.NioClientSocketPipelineSink类中发生。

And also, as I see from logs, it throws following exception: 而且,正如我从日志中看到的那样,它引发以下异常:

NioClientSocketPipelineSink:internalWarn:105 - Unexpected exception in the selector loop.
java.nio.channels.CancelledKeyException
    at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:55)
    at sun.nio.ch.SelectionKeyImpl.readyOps(SelectionKeyImpl.java:69)
    at java.nio.channels.SelectionKey.isConnectable(SelectionKey.java:318)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processSelectedKeys(NioClientSocketPipelineSink.java:369)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:292)
    at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
    at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:44)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

Btw, i'm not sure where is a problem. 顺便说一句,我不确定哪里出了问题。

Is it ElasticSearch issue? 是ElasticSearch问题吗? Or embedded Netty? 还是嵌入式Netty? Or my server/app configuration? 还是我的服务器/应用程序配置?

I'm using Ubuntu 64 11.10, Sun Java 1.6.0_26-b03 and Elastic Search 0.18.5 我正在使用Ubuntu 64 11.10,Sun Java 1.6.0_26-b03和Elastic Search 0.18.5


Update 更新

Seems that it was because I've tried to open and close connection for every request to ElasticSearch. 似乎是因为我尝试打开和关闭对ElasticSearch的每个请求的连接。 And it was, i guess, some kind of concurrency issue. 我猜这是某种并发问题。

Fixed by opening a connection to Elastic Search just once, on startup. 通过在启动时仅一次打开与Elastic Search的连接来解决。

Can you check with latest netty version (3.2.7.Final) and see if it fix it ? 您可以查看最新的netty版本(3.2.7.Final)并查看其是否修复了该版本吗? I think we fixed a bug there which could cause an infinity loop in the selector and so consume 100 % cpu. 我认为我们在那里修复了一个错误,该错误可能导致选择器中出现无限循环,从而消耗100%的CPU。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM