Stop the Build Queue Bottleneck: Optimizing Jenkins CI Pipelines on High-Performance KVM
It is 3:00 AM. You just pushed a hotfix to the master branch. Now, you wait. And wait. The Jenkins console output hangs on "Building workspace..." for what feels like an eternity. If this sounds familiar, your bottleneck isn't your code—it's your infrastructure.
In the DevOps world of 2014, we talk endlessly about "Continuous Integration," but we rarely talk about the metal running it. Most development teams in Europe are tossing their build servers onto cheap, oversold OpenVZ containers. This is a critical error. CI/CD processes are inherently I/O heavy—unpacking JARs, compiling binaries, running `npm install`, and firing up database integration tests. On a shared kernel, your build time is at the mercy of your neighbor's MySQL query.
I have seen pipelines reduce deployment times from 20 minutes to 3 minutes simply by moving from shared hosting to dedicated KVM slices with proper I/O isolation. Let's fix your pipeline.
The Hidden Killer: I/O Wait
When you run a build, your CPU is rarely the limiting factor. It's the disk. Specifically, random Read/Write operations. If you are running Jenkins on a standard VPS provider, you are likely suffering from "Steal Time"—cycles your CPU waits while the hypervisor serves another tenant.
To diagnose this, stop looking at `top`. Look at `iostat`. If your `%iowait` is consistently above 5% during a build, your storage is choking.
Optimization 1: Move the Workspace to RAM
Since build artifacts are ephemeral, why write them to disk at all? If you have enough RAM (and you should), mounting your Jenkins workspace as a tmpfs can eliminate disk latency entirely.
Here is how we configure this on a CentOS 6 box:
# /etc/fstab entry for a 2GB RAM disk
tmpfs /var/lib/jenkins/workspace tmpfs size=2g,noatime,mode=1777 0 0
Run mount -a and restart Jenkins. Your heavy compilation steps now happen at the speed of memory, not the speed of a spinning platter. Note: This clears on reboot, which is exactly what we want for a clean slate.
Tuning the JVM for Jenkins
Jenkins is a Java beast. Out of the box, on many distributions like Debian Wheezy or Ubuntu 12.04 LTS, the default heap settings are conservative. If your build server swaps, the pipeline dies. We need to lock the heap and prevent garbage collection pauses from stalling the agent.
Edit your configuration file (usually /etc/default/jenkins or /etc/sysconfig/jenkins):
# Optimize for a server with 8GB RAM dedicated to Jenkins
JAVA_ARGS="-Xmx6g -Xms6g -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled"
Pro Tip: Setting-Xmxand-Xmsto the same value prevents the JVM from constantly resizing the heap, which saves CPU cycles during intensive builds.
The Virtualization War: OpenVZ vs. KVM
This is where the "CoolVDS" architectural advantage becomes non-negotiable. Many budget hosts use OpenVZ. In OpenVZ, you share the kernel. You cannot load your own kernel modules, and more importantly, the disk buffer cache is shared. One noisy neighbor rendering video files can fill the buffer, flushing your build artifacts out of the cache.
At CoolVDS, we standardize on KVM (Kernel-based Virtual Machine). KVM treats your VPS as a distinct machine. You get your own kernel, your own memory space, and dedicated I/O queues.
| Feature | OpenVZ (Budget VPS) | KVM (CoolVDS) |
|---|---|---|
| Kernel | Shared | Dedicated |
| Swap Management | Host Controlled (Unreliable) | User Controlled |
| Docker Support | Difficult/Impossible (Requires older kernels) | Native (Kernel 3.8+) |
| Performance Consistency | Fluctuates wildly | Stable & Guaranteed |
For CI/CD, predictability is more valuable than raw burst speed. You need to know that a build takes 4 minutes, every single time.
Accelerating Deployments with SSH Multiplexing
Once the build passes, you deploy. If you are using Capistrano, Fabric, or simple rsync scripts, your server initiates a new SSH handshake for every single file transfer or command. This negotiation takes time, especially if you are hopping across Europe.
Configure your build agent to reuse SSH connections. Add this to your ~/.ssh/config on the Jenkins user:
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
ControlPersist 600
This creates a master socket. Subsequent commands reuse the existing tunnel. I have measured this reducing deployment phases from 90 seconds to 15 seconds when deploying to multiple nodes.
Data Sovereignty and Local Latency
We are operating in a post-Snowden world. Privacy matters. If your team is based in Oslo or Stavanger, sending your data across the Atlantic to US-based servers is not just a latency issue; it's a governance risk. The Norwegian Data Protection Authority (Datatilsynet) is increasingly vigilant about where personal data flows.
Hosting your build infrastructure and staging environments within Norway offers two distinct advantages:
- NIX Connectivity: CoolVDS peers directly at the Norwegian Internet Exchange (NIX). If your office is in Norway, your latency to the build server is effectively zero (sub-5ms). This makes SCP uploads of large artifacts instant.
- Compliance: Keeping your staging databases—which often contain scrubbed but sensitive customer data—on Norwegian soil simplifies compliance with local acts like Personopplysningsloven.
The Hardware Reality: NVMe is the Future
While standard SSDs are a massive leap over rotating rust, the enterprise market is shifting toward PCIe-based storage (NVMe). This technology unlocks the true potential of flash storage, bypassing the legacy SATA interface limits. While rare in the consumer market today, CoolVDS is rolling out high-performance storage tiers that utilize this throughput. For a database-heavy integration test suite, the difference is night and day.
Final Configuration: The Build Script
Stop clicking buttons in the Jenkins UI. Define your build logic in a script committed to your repository. This ensures version control for your build logic as well as your application code.
#!/bin/bash
set -e # Fail on first error
# ensure we are clean
mvn clean
# run tests with increased memory for the surefire plugin
export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"
mvn test
# If successful, package and deploy
if [ $? -eq 0 ]; then
echo "Tests Passed. Deploying to Staging on CoolVDS..."
rsync -avz --exclude 'test' target/myapp.war deployer@staging.coolvds.com:/opt/tomcat/webapps/
fi
Infrastructure is not a commodity; it is a component of your software stack. If your CI pipeline is slow, your developers lose focus, context switches increase, and code quality drops. Don't let your infrastructure be the reason you miss a deadline.
Ready to cut your build times in half? Deploy a high-frequency KVM instance on CoolVDS today and experience the power of dedicated resources and low-latency local peering.