0
0
Jenkinsdevops~10 mins

Performance tuning in Jenkins - Commands & Configuration

Choose your learning style9 modes available
Introduction
Jenkins can slow down when many jobs run or when resources are limited. Performance tuning helps Jenkins run faster and handle more work smoothly.
When Jenkins jobs take too long to start or finish
When the Jenkins server uses too much CPU or memory
When many users access Jenkins at the same time and it becomes slow
When build queues grow and jobs wait too long to run
When Jenkins logs grow too large and slow down the system
Config File - jenkins.xml
jenkins.xml
<?xml version="1.0" encoding="UTF-8"?>
<jenkins>
  <numExecutors>4</numExecutors>
  <quietPeriod>5</quietPeriod>
  <scmCheckoutRetryCount>2</scmCheckoutRetryCount>
  <workspaceDir>${JENKINS_HOME}/workspace/${ITEM_FULL_NAME}</workspaceDir>
  <buildsDir>${JENKINS_HOME}/builds/${ITEM_FULL_NAME}</buildsDir>
  <systemMessage>Jenkins tuned for better performance</systemMessage>
</jenkins>

numExecutors: Number of parallel jobs Jenkins can run.

quietPeriod: Wait time before starting a job to group changes.

scmCheckoutRetryCount: Number of retries for source code checkout to avoid failures.

workspaceDir and buildsDir: Paths to store job data efficiently.

systemMessage: Shows a message on Jenkins dashboard.

Commands
Starts Jenkins with a maximum of 100 HTTP handler threads to handle more simultaneous requests.
Terminal
java -jar jenkins.war --httpPort=8080 --handlerCountMax=100
Expected OutputExpected
Running from: /home/jenkins/jenkins.war INFO: Jenkins is fully up and running INFO: HTTP connector started on port 8080 INFO: Maximum handler count set to 100
--httpPort=8080 - Sets the HTTP port Jenkins listens on
--handlerCountMax=100 - Increases max concurrent HTTP handlers for better performance
Runs a Groovy script via Jenkins CLI to enable performance optimizations like disabling unused plugins.
Terminal
jenkins-cli.jar -s http://localhost:8080 groovy = < enable_performance_optimizations.groovy
Expected OutputExpected
Performance optimizations enabled successfully
Restarts Jenkins service to apply configuration and performance changes.
Terminal
systemctl restart jenkins
Expected OutputExpected
No output (command runs silently)
Checks the status of Jenkins jobs to verify Jenkins is responsive after tuning.
Terminal
curl -s http://localhost:8080/api/json?tree=jobs[name,color] | jq
Expected OutputExpected
{ "jobs": [ {"name": "build-app", "color": "blue"}, {"name": "test-app", "color": "red"} ] }
-s - Runs curl silently without progress output
Key Concept

If you remember nothing else from performance tuning Jenkins, remember: adjust executors and resource limits to match your workload.

Common Mistakes
Setting numExecutors too high without enough CPU or memory
Jenkins will overload the server causing slowdowns or crashes
Set numExecutors based on available CPU cores and memory capacity
Not restarting Jenkins after changing configuration
Changes will not take effect until Jenkins restarts
Always restart Jenkins service after config changes
Ignoring plugin performance impact
Unused or heavy plugins can slow Jenkins down
Disable or remove plugins that are not needed
Summary
Start Jenkins with increased handler count to handle more requests.
Configure numExecutors and retry counts in jenkins.xml for better job management.
Restart Jenkins to apply changes and verify responsiveness with API calls.