NotSoShabby
NotSoShabby

Reputation: 3688

Jenkins in a container is much slower than on the server itself

We recently had our jenkins redone. We decided to have the new version on a docker container on the server.

While migrating, I noticed that the jenkins is MUCH slower when its in a container than when it ran on the server itself.

This is a major issue and could mess up our migration.

I tried looking for ways to give more resources to the container with not much help.

How can I speed the jenkins container/ give it all the resources it needs on the server (the server is dedicated only to jenkins).

Also, how do I devide these resources when I want to start up slave containers as well?

Upvotes: 6

Views: 7762

Answers (1)

Thomasleveil
Thomasleveil

Reputation: 103965

Disk operations

One thing that can go slow with Docker is when the process running in a container is making a lot of I/O calls to the container file system. The container file system is a union file system which is not optimized for speed.

This is where docker volumes are useful. Additionally to providing a location on the file system which survives container deletion, disk performance on a docker volume is good.

The Jenkins Docker image defines the JENKINS_HOME location as a docker volume, so as long as your Jenkins jobs are making their disk operations within that location you should be fine.

If you determine that disk access on that volume is still too slow, you could customize the mount location of that volume on your docker host so that it would end up being mounted on a fast drive such as a SSD.

Another trick is to make a docker volume mounted to RAM with tmpfs. Note that such a volume does not offer persistence and that data at that location will be lost when the container is stopped or deleted.


JVM memory exhaustion / Garbage collector

As Jenkins is a Java application, another potential issue comes in mind: memory exhaustion. In the case the JVM on which the Jenkins process runs on is too limited in memory, the Java garbage collector will runs too frequently. You can witness that when you realize your Java app is using too much CPU (the garbage collector uses CPU). If that is the case, give more memory to the JVM:

docker run-p 8080:8080 -p 50000:50000 --env JAVA_OPTS="-Xmx2048m -Djava.awt.headless=true" jenkins/jenkins:lts

Network

Docker containers have a virtual network stack and custom network settings. You also want to make sure that all network related operation are fast.

The DNS server might be an issue, check it by executing ping <some domain name> from the Jenkins container.

Upvotes: 4

Related Questions