{"action":"created","issue":{"url":"https://api.github.com/repos/logstash-plugins/logstash-input-kafka/issues/52","labels_url":"https://api.github.com/repos/logstash-plugins/logstash-input-kafka/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/logstash-plugins/logstash-input-kafka/issues/52/comments","events_url":"https://api.github.com/repos/logstash-plugins/logstash-input-kafka/issues/52/events","html_url":"https://github.com/logstash-plugins/logstash-input-kafka/issues/52","id":121991527,"number":52,"title":"High CPU usage in logstash 2.0","user":{"login":"caipeichao","id":1661871,"avatar_url":"https://avatars.githubusercontent.com/u/1661871?v=3","gravatar_id":"","url":"https://api.github.com/users/caipeichao","html_url":"https://github.com/caipeichao","followers_url":"https://api.github.com/users/caipeichao/followers","following_url":"https://api.github.com/users/caipeichao/following{/other_user}","gists_url":"https://api.github.com/users/caipeichao/gists{/gist_id}","starred_url":"https://api.github.com/users/caipeichao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caipeichao/subscriptions","organizations_url":"https://api.github.com/users/caipeichao/orgs","repos_url":"https://api.github.com/users/caipeichao/repos","events_url":"https://api.github.com/users/caipeichao/events{/privacy}","received_events_url":"https://api.github.com/users/caipeichao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-12-14T07:48:21Z","updated_at":"2015-12-14T21:45:38Z","closed_at":null,"body":"Hi, we are using logstash 2.0 to collect logs. But we found it consumed too much CPU resource, over 300% (8 cores).\r\n\r\nHere is the config:\r\n\r\n```\r\ninput {\r\n    kafka {\r\n        group_id => \"logstash\"\r\n        topic_id => \"logstash\"\r\n        zk_connect => \"192.168.1.101:2181,192.168.1.102:2181,192.168.1.103:2181/kafkalog\"\r\n    }\r\n}\r\n\r\noutput {\r\n    elasticsearch {\r\n\t    hosts => [ \"192.168.1.201:9200\",\"192.168.1.202:9200\",\"192.168.1.203:9200\"]\r\n        index => \"logstash-%{type}-%{+YYYY.MM.dd}\"\r\n        index_type => \"%{type}\"\r\n        workers => 24\r\n        template_overwrite => true\r\n    }\r\n}\r\n```\r\n\r\nHere is the top for logstash process:\r\n\r\n```\r\n45520 admin     20   0 5145m 770m  13m R 95.4  1.2   3919:16 <kafka\r\n16493 admin     20   0 5145m 770m  13m S  9.9  1.2  10:00.87 <kafka\r\n16494 admin     20   0 5145m 770m  13m R  8.0  1.2  10:22.48 <kafka\r\n45611 admin     20   0 5145m 770m  13m S  6.0  1.2 219:50.52 <kafka\r\n45536 admin     20   0 5145m 770m  13m R  4.0  1.2 295:32.40 >output\r\n45548 admin     20   0 5145m 770m  13m S  4.0  1.2 105:37.91 >elasticsearch.\r\n45608 admin     20   0 5145m 770m  13m S  4.0  1.2  47:13.84 >elasticsearch.\r\n45635 admin     20   0 5145m 770m  13m S  4.0  1.2  47:29.15 >elasticsearch.\r\n45638 admin     20   0 5145m 770m  13m S  4.0  1.2  47:09.60 >elasticsearch.\r\n45363 admin     20   0 5145m 770m  13m S  2.0  1.2  88:07.72 java\r\n45364 admin     20   0 5145m 770m  13m S  2.0  1.2  88:04.00 java\r\n45365 admin     20   0 5145m 770m  13m S  2.0  1.2  88:13.39 java\r\n45366 admin     20   0 5145m 770m  13m S  2.0  1.2  88:14.11 java\r\n45367 admin     20   0 5145m 770m  13m S  2.0  1.2  88:12.28 java\r\n45368 admin     20   0 5145m 770m  13m S  2.0  1.2  88:05.51 java\r\n45372 admin     20   0 5145m 770m  13m S  2.0  1.2  39:54.07 java\r\n45373 admin     20   0 5145m 770m  13m S  2.0  1.2  41:29.71 java\r\n45543 admin     20   0 5145m 770m  13m S  2.0  1.2 107:13.18 >elasticsearch.\r\n45544 admin     20   0 5145m 770m  13m S  2.0  1.2 106:05.68 >elasticsearch.\r\n45545 admin     20   0 5145m 770m  13m S  2.0  1.2 105:52.78 >elasticsearch.\r\n45546 admin     20   0 5145m 770m  13m S  2.0  1.2 105:43.77 >elasticsearch.\r\n45549 admin     20   0 5145m 770m  13m S  2.0  1.2 106:16.93 >elasticsearch.\r\n45550 admin     20   0 5145m 770m  13m S  2.0  1.2 105:44.84 >elasticsearch.\r\n45552 admin     20   0 5145m 770m  13m S  2.0  1.2 106:15.47 >elasticsearch.\r\n45554 admin     20   0 5145m 770m  13m S  2.0  1.2 106:38.47 >elasticsearch.\r\n45555 admin     20   0 5145m 770m  13m S  2.0  1.2 106:31.77 >elasticsearch.\r\n45557 admin     20   0 5145m 770m  13m S  2.0  1.2 105:34.25 >elasticsearch.\r\n45558 admin     20   0 5145m 770m  13m R  2.0  1.2 105:55.13 >elasticsearch.\r\n45561 admin     20   0 5145m 770m  13m S  2.0  1.2 106:28.72 >elasticsearch.\r\n45562 admin     20   0 5145m 770m  13m S  2.0  1.2 106:50.73 >elasticsearch.\r\n```\r\n\r\nHere is the jstack of thread-id 45520:\r\n\r\n```\r\n\"<kafka\" daemon prio=10 tid=0x00007ff37435b800 nid=0xb1d0 runnable [0x00007ff37bbe6000]\r\n   java.lang.Thread.State: RUNNABLE\r\n        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:134)\r\n        at rubyjit.LogStash::Inputs::Base$$stop?_5ecc17de0faba55421c72ac5c66b2d232a0c2171273061103.__file__(/home/admin/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.0.0-java/lib/logstash/inputs/base.rb:89)\r\n        at rubyjit.LogStash::Inputs::Base$$stop?_5ecc17de0faba55421c72ac5c66b2d232a0c2171273061103.__file__(/home/admin/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.0.0-java/lib/logstash/inputs/base.rb)\r\n        at org.jruby.internal.runtime.methods.JittedMethod.call(JittedMethod.java:141)\r\n        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:134)\r\n        at org.jruby.ast.FCallNoArgNode.interpret(FCallNoArgNode.java:31)\r\n        at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:60)\r\n        at org.jruby.ast.WhileNode.interpret(WhileNode.java:127)\r\n        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)\r\n        at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)\r\n        at org.jruby.ast.RescueNode.executeBody(RescueNode.java:221)\r\n        at org.jruby.ast.RescueNode.interpret(RescueNode.java:116)\r\n        at org.jruby.ast.BeginNode.interpret(BeginNode.java:83)\r\n        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)\r\n        at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)\r\n        at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)\r\n        at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)\r\n        at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:203)\r\n        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)\r\n        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)\r\n        at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)\r\n        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)\r\n        at org.jruby.ast.RescueNode.executeBody(RescueNode.java:221)\r\n        at org.jruby.ast.RescueNode.interpret(RescueNode.java:116)\r\n        at org.jruby.ast.EnsureNode.interpret(EnsureNode.java:96)\r\n        at org.jruby.ast.BeginNode.interpret(BeginNode.java:83)\r\n        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)\r\n        at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)\r\n        at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)\r\n        at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)\r\n        at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:203)\r\n        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)\r\n        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)\r\n        at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)\r\n        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)\r\n        at org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)\r\n        at org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:206)\r\n        at org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:194)\r\n        at org.jruby.runtime.Interpreted19Block.call(Interpreted19Block.java:125)\r\n        at org.jruby.runtime.Block.call(Block.java:101)\r\n        at org.jruby.RubyProc.call(RubyProc.java:290)\r\n        at org.jruby.RubyProc.call(RubyProc.java:228)\r\n        at org.jruby.internal.runtime.RubyRunnable.run(RubyRunnable.java:99)\r\n        at java.lang.Thread.run(Thread.java:745)\r\n```"},"comment":{"url":"https://api.github.com/repos/logstash-plugins/logstash-input-kafka/issues/comments/164569593","html_url":"https://github.com/logstash-plugins/logstash-input-kafka/issues/52#issuecomment-164569593","issue_url":"https://api.github.com/repos/logstash-plugins/logstash-input-kafka/issues/52","id":164569593,"user":{"login":"r-tock","id":11711723,"avatar_url":"https://avatars.githubusercontent.com/u/11711723?v=3","gravatar_id":"","url":"https://api.github.com/users/r-tock","html_url":"https://github.com/r-tock","followers_url":"https://api.github.com/users/r-tock/followers","following_url":"https://api.github.com/users/r-tock/following{/other_user}","gists_url":"https://api.github.com/users/r-tock/gists{/gist_id}","starred_url":"https://api.github.com/users/r-tock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r-tock/subscriptions","organizations_url":"https://api.github.com/users/r-tock/orgs","repos_url":"https://api.github.com/users/r-tock/repos","events_url":"https://api.github.com/users/r-tock/events{/privacy}","received_events_url":"https://api.github.com/users/r-tock/received_events","type":"User","site_admin":false},"created_at":"2015-12-14T21:45:38Z","updated_at":"2015-12-14T21:45:38Z","body":"This is a single cpu node."}}