Skip to content
James Ross
articlePublished Updated 8 min read

A remote BuildKit server cut compose builds by 62%

By James Ross

A remote BuildKit server took a Docker Compose build from 678 seconds to 258 seconds, a 62% cut, by moving compilation off the app host and keeping the layer cache on local NVMe. The build server was retired on 2026-11-18, which makes it a good case for when a second machine is worth the operational cost and when it is not.

An app host sending a build to a separate build server with cache stacks and a stopwatch dial, showing a remote BuildKit speedup.

The platform this BuildKit server served runs 19 or more applications across 28 projects, so every second a build spends on that host is a second the host is not spending on live traffic. The same argument drove the WordPress-to-Workers migration: the cheapest request is the one that never reaches an origin.

Why move builds off the app host?

Because a build is a burst of CPU, memory and disk I/O that competes directly with the containers serving traffic. On a host running 19 or more applications, the build is often the largest unplanned workload and the one most likely to arrive during business hours.

A Docker build is not a light operation. It pulls base images, installs language toolchains, compiles or bundles source, and writes a new image layer by layer. On the app host, every step shares a kernel, page cache, disk and memory budget with the running applications. The scheduler is fair, but fair is not harmless: a build that pins every core makes every request slower for that whole time.

The failure mode is not only latency. A build that allocates without a bound can consume the host’s memory and trigger the kernel OOM killer, which may choose a process belonging to a live application. That is exactly what happened on this platform before the build memory cap: a large build took every hosted site down for about 21 minutes.

Moving the build to another machine changes the containment problem. The app host keeps its CPU, memory and disk for the applications, and the build host can be sized, capped and restarted without touching production.

What does a remote BuildKit setup look like?

The build daemon (buildkitd) runs on a separate machine and listens on a TCP port. The app host registers it as a Buildx builder using the remote driver, then sends build contexts to it. The image is built on the remote machine, not on the platform host.

app host                              build host
--------                              ----------
docker compose build                  buildkitd (TCP + mTLS)
  -> buildx remote driver  --------->  pull base images
  <- image / registry reference <----  run build steps
                                       cache on local NVMe

The setup has four parts:

  1. A BuildKit daemon on the build host. It runs as a systemd service, with its own data directory on the NVMe volume.
  2. A certificate authority and two certificate pairs. One pair for the daemon, one for the client. The daemon is started with --tlscacert, --tlscert and --tlskey; the client passes cacert, cert, key and servername as driver options.
  3. A Buildx builder on the app host. docker buildx create --driver remote points at the daemon’s address and holds the client certificate paths.
  4. A way for the built image to reach the platform. The app host pulls the result from the registry or receives it through the builder’s output; either way, it no longer runs the compiler.

The Docker documentation is blunt about the alternative: exposing BuildKit over TCP without TLS “allows arbitrary access to BuildKit without credentials”. A BuildKit daemon can run arbitrary build steps on its host, so an open port is effectively remote code execution with a friendly API. TLS is not optional on a shared network.

Why mTLS rather than a private network alone?

Mutual TLS authenticates both ends: the client verifies the daemon’s certificate, and the daemon verifies the client’s certificate before accepting a build. A private network or VPN reduces exposure, but it does not distinguish one authorised client from any other machine that reaches the port.

The certificate is also the revocation unit. If a laptop that could reach the builder is lost, removing its client certificate stops it from submitting builds without changing the daemon’s address or firewall rules. That is a simpler operational story than rotating a shared token or renumbering the network.

The cost is real: certificates expire, the daemon needs the correct SAN and server name, and a mismatched servername produces a TLS error that looks like a network failure. The setup only pays for itself if the build traffic is frequent enough that the certificate handling becomes routine.

How much did the NVMe cache matter?

The 678-to-258 second result is not only about a faster CPU. A large part of it is the cache: BuildKit stores layers content-addressed on the build host, and a persistent local cache means unchanged steps are reused between builds (Docker cache docs).

Three properties of the build host’s cache mattered:

  • It persisted. The cache lived on the host’s NVMe, not in an ephemeral CI runner that starts empty. A rebuild after a one-line change did not re-download base images or reinstall dependencies.
  • It was local. Reading layers from local NVMe avoids the latency and contention of a network volume, and it keeps cache I/O off the app host’s disk.
  • It was disposable. The cache could be pruned or wiped without touching production. That matters when a corrupted layer or a bad base image needs to be evicted.

Cache reuse is also why the improvement is workload-specific. A build that changes its dependency lockfile on every run gets much less from a warm cache. The 62% figure belongs to this build, with this change pattern.

The 678 s to 258 s result

The measurement was a Compose build of the application, before and after moving it to the remote daemon. 678 seconds became 258 seconds, a saving of 420 seconds, or 61.9%.

That number comes with two caveats. It is one build of one project on one pair of machines, not a benchmark across the fleet. And it measures wall-clock time, which includes context transfer and image export; the CPU time saved on the app host is larger than the wall-clock difference suggests, because the host is no longer doing the work at all.

The operational result mattered more than the percentage. Deploys no longer ran on the platform host, and a runaway build could no longer starve the sites. Those are the reasons to move a build, and the speed is the bonus.

When is a build server worth it?

Option Where the build runs Cache Isolation from production Operational cost Best for
Local Docker daemon on the app host Platform host Local layers None Smallest Small fleets, short builds
Buildx container driver on the app host Platform host, separate container Named volume Partial: CPU and memory still shared Low Medium builds that need a cleaner daemon
Hosted CI Vendor Vendor cache Full Medium Teams already using CI for tests
Remote BuildKit Dedicated host Persistent local NVMe Full Medium to high: certificates, patching, another host Frequent, heavy builds on a shared platform

Which should you choose?

Choose remote BuildKit when three things are true: builds are long enough to hurt (minutes, not seconds), they run often enough that cache reuse matters, and the app host also serves production traffic. The dedicated machine then buys isolation, a warm cache and a stable build environment.

Stay with the local daemon when builds are short, deploys are infrequent, or the platform host has spare capacity and nothing latency-sensitive on it. A second machine is not free: it needs patching, certificates, monitoring, backups of its cache configuration and a plan for what happens when it is down.

Choose hosted CI when the team already runs tests there and wants build minutes billed rather than machines maintained. The trade-off is less control over the cache and the network path, and a build that leaves your infrastructure.

Why was this build server retired?

The build server was retired on 2026-11-18. The infrastructure notes record the date and the result, not a detailed post-mortem, so the honest version is that the notes do not record a reason. The machine was removed, and the result it produced remains the useful part.

That ending is part of the lesson rather than a contradiction of it. A build server is capacity you have to keep feeding: an operating system to patch, a daemon to upgrade, certificates to rotate, a cache to prune and a monitoring check to own. When the build volume or the platform layout changes, the same 62% can stop justifying that work.

The decision is not “build servers are good” or “build servers are bad”. It is whether the isolation and cache are worth another machine this quarter. For a period on this platform, they were.

What broke and what we changed

Builds on the app host were a production risk, not just a slow deploy. A large build exhausted the host’s memory and took every hosted site down for about 21 minutes. That incident led to the per-step cgroup cap, and it is the strongest argument for moving the work off the host entirely.

The remote builder became a dependency. With builds routed to another machine, a builder that was down meant no deploys. The failure mode moved from “production gets slow” to “deploys stop”, which is safer but still needs to be watched. A build host needs the same uptime check as the platform.

Certificates are the fragile part. mTLS is the right control and the least pleasant thing to operate. In practice, an expired client certificate or a mismatched server name produces a build failure that looks like a network problem, so the certificate expiry has to be on the same calendar as everything else.

The cache has to be treated as disposable. A warm NVMe cache is the main performance win, and it is also a source of confusing failures when a layer is corrupt or a base image changes underneath it. The cache needs a documented way to be pruned and rebuilt.

The 62% was real when it was measured. It was not a permanent property of the platform, and the machine was retired on 2026-11-18. Measure the win, keep the configuration, and be willing to remove the server when the arithmetic changes.

Frequently asked questions

What is a remote BuildKit server?

It is a buildkitd daemon running on a different machine from the one invoking the build. The client uses the Buildx remote driver to send the build context and receive the result. Build steps execute on the remote host, which needs its own CPU, memory, disk and cache, and a secure connection such as mutual TLS.

Why is Docker Compose build slow on a busy host?

Because the build competes with everything else on the host for CPU, memory and disk. Compose builds run through BuildKit, which can execute independent stages in parallel, so the peak load is higher than a single-threaded compile. On a host running many application containers, the build is the largest burst workload and the one most likely to cause contention.

Is mTLS required for a remote BuildKit daemon?

It is required if the daemon is reachable by anything you do not fully trust. Docker's documentation warns that exposing BuildKit over TCP without TLS allows arbitrary access without credentials, because a BuildKit client can run arbitrary build steps on the daemon's host. mTLS authenticates the client and encrypts the connection.

How much faster is a remote build?

In this case, 678 seconds became 258 seconds, a 62% reduction. There is no general number: the gain depends on the build's cache behaviour, the speed of the build host, the network path for the context and the image, and how much contention the app host was experiencing. A dependency-heavy build with a warm cache gains the most.

Does a remote builder need its own cache?

It needs a persistent cache to get the benefit. BuildKit's cache is content-addressed and local to the daemon, so a host with an empty cache rebuilds everything. Storing the cache on local NVMe keeps it fast and keeps the I/O away from the app host's disks. The cache should be prunable without affecting production.

What happens when the build server goes down?

Deploys stop, but production keeps running. That is the trade: the failure moves off the app host and onto the deploy path. The build host needs monitoring, a documented restart procedure and a fallback plan, which may be as simple as temporarily building on the app host with the memory cap in place.

When should you retire a build server?

When the builds it serves become infrequent or small enough that a warm cache and isolation no longer pay for another machine to patch and monitor. This one was retired on 2026-11-18. The right time is a capacity decision, not a failure: if the platform layout or deploy volume changes, redo the arithmetic.