question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

High CPU usage when using version 254

See original GitHub issue

Hello,

I’ve been using JMXTrans to transfer some 301 metrics every minute. At the start up everything works fine, CPU usage is about 15%. Then after a while CPU usage starts to climb progressively until reaching 95% constantly. I checked with mission control the threads that are demanding CPU and found some Stormpot-pool1-thread-XX on the top of the list.

jmxtrans_threads_consommant_cpu_1

I could correlate the CPU increase with exception of this type:

java.net.SocketException: Connection reset
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
        at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
        at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282)
        at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
        at java.io.OutputStreamWriter.write(OutputStreamWriter.java:207)
        at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:129)
        at java.io.BufferedWriter.write(BufferedWriter.java:230)
        at java.io.Writer.write(Writer.java:157)
        at com.googlecode.jmxtrans.model.output.GraphiteWriter2.write(GraphiteWriter2.java:78)
        at com.googlecode.jmxtrans.model.output.support.WriterPoolOutputWriter.doWrite(WriterPoolOutputWriter.java:54)
        at com.googlecode.jmxtrans.model.output.support.ResultTransformerOutputWriter.doWrite(ResultTransformerOutputWriter.java:61)
        at com.googlecode.jmxtrans.jmx.ResultProcessor$1.run(ResultProcessor.java:58)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

I assumed according to these facts that the high CPU usage is caused by the Stormpot writer pools. I tried to change the code and include an invalidate statement on the writer that raised this exception as follows (class com.googlecode.jmxtrans.model.output.support.WriterPoolOutputWriter):

 public void doWrite(Server server, Query query, Iterable<Result> results)
    throws Exception
  {
    try
    {
      WriterPoolable writerPoolable = (WriterPoolable)this.writerPool.claim(this.poolClaimTimeout);
      try
      {
        this.target.write(writerPoolable.getWriter(), server, query, results);
      }
      catch (Exception ioe)
      {
        writerPoolable.invalidate();
        this.logger.warn("Invalidate WriterPoolable", ioe);
        throw ioe;
      }
      finally
      {
        writerPoolable.release();
      }
    }
    catch (InterruptedException e)
    {
      throw new IllegalStateException("Could not get writer from pool, please check if the server is available");
    }
  }

This change didn’t help as I reproduced the CPU high usage.

According to the Stormpot documentation, the expiration takes effect only after the release of the pooled object and it has to be delegated to Stormpot itself by defining an Expiration strategy.

I could not test more code changes as I got some other priority tasks to do. But I still need to fix this issue in order to use JMXTrans for monitoring. Is it possible to check this issue?

As a second question: is there a way not to use poolable writer as the pool contains always 1 instance and the writers are instantiated once per request as shows the class histogram bellow jmxtrans_nb_instances

Thanks in advance for your help and your support.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:54 (38 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisvestcommented, May 13, 2016

Precise sleeping - your wait/notify suggestion - is too complicated and risky to tackle in a 2.4.1 release. And I’m redoing the background task scheduling in 3.0 anyway.

I found 2 other cases where it’s using more CPU than it strictly needs. I want to fix those as well.

1reaction
gehelcommented, May 11, 2016

Thanks a lot for that PR! I had in mind something closer to a circuit breaker, but your implementation with the retryer seems just as good.

And send me an email if you want in. JmxTrans is looking for talents!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Guidance for troubleshooting high CPU usage - Windows Server
Introduces general guidance for troubleshooting scenarios in which you experience high CPU usage.
Read more >
High CPU usage on reading specific file (#254) · Issues
A specific PDF file (http://ubuntuone.com/4ELfHGFXVtDAtU0lWsLT6G) causes very high CPU load and takes a long time to render using ...
Read more >
Nexus 5596 high cpu utilization caused by igmp
I have two Nexus 5596 and four extenders. It switches work in vPC domain and make inter-vlan routing (I use vrrp). But I...
Read more >
How can I produce high CPU load on Windows? - Super User
@JonathanRioux: Same solution, download the resource toolkit linked in the answer and use consume.exe . The application isn't included in any version of...
Read more >
rhds81 modrdn operation and 100% cpu use in replication ...
Description of problem: high cpu use investigation likely related to successive modrdn operations. customer's environment is 2x mmr and 3 consummers, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found