Jenkins running at very high CPU usage

33,727

Solution 1

As it turned out, my issue was that several jobs had thousands of old builds. This was fine in Jenkins 1.6 but it's a problem in 2.5 (I guess maybe Jenkins tries to load all the builds into memory when you view the job overview page). To fix it, I just deleted most of the old builds from the problem jobs using this strategy and then reloaded jenkins. Worked like a charm!

I also set the "discard old builds" plugin to keep only the 50 most recent builds, to prevent this from happening again.

Solution 2

Whenever a request comes in, Jenkins will spawn some threads to serve the request. After upgrading Jenkins, it might have invoked at high throttle at that time. Plz check the CPU and memory usage of Jenkins server while the following scenarios :

  • Jenkins is idle and no other apps are running on the server.
  • Scheduled a build and no other apps are running on the server.

And compare the behaviors which could help you out to determine whether Jenkins or running jenkins in parallel with other apps are really making trouble.

As @vlp said, try to monitor the jenkins application via JVisualVM with Jstad configuration to hook in. Refer this link to Configure JvisualVM with Jstad.

Solution 3

I have noticed a couple of reasons for abnormal CPU usage with my Jenkins install on Windows 7 Ultimate.

  1. I had recently upgraded from v2.138 to v2.140 plus added a few additional plugins. I started noticing a problem with the Jenkins java executable taking up to 60% of my CPU time every time a job would trigger. None of the jobs were CPU bound, just grabbing data from external servers, so it didn't make any sense. It was fixed with a simple restart of the Jenkins service. I assume the upgrade just didn't finish cleanly.

  2. Java Garbage Collection was throwing errors and hogging the CPU when running with the default memory settings. It was probably overkill, but I went wild and upped the Java Heap Space for Jenkins from the default 256mb to 4gb; which solved this problem for me.

    See this solution for instructions: https://stackoverflow.com/a/8122566/4479786

Solution 4

2.5 seems to be a development release, while 1.6 is their Long Term Support version. Thus it seems logical that you should expect some regressions when using the bleeding edge version. The bounty on this question is proof that other users are experiencing this as well. The solution is to report a bug on the Jenkins bug tracker. You can temporarily downgrade to the known good version for now.

Share:
33,727
Matt Korostoff
Author by

Matt Korostoff

Updated on July 09, 2022

Comments

  • Matt Korostoff
    Matt Korostoff almost 2 years

    I recently upgraded from Jenkins 1.6 to 2.5. After I did this, I noticed very high CPU usage, sometimes over 300% (there are only 4 cores, so I don't think it could go over 400%). I'm not sure where to begin debugging this, but here's a thread dump and some screenshots from top/htop

    htop htop

    top: top