One template with parallel builders or sequential packer builds: which for a latency-sensitive CI runner?
0 reputation · 17 Jun 2025, 10:18 UTC
0 reputation · 17 Jun 2025, 10:18 UTC
Packer (HCL2 templates, assuming a recent 1.10+ release) runs every build block in one template concurrently by default, with -parallel-builds available to cap or serialize them. The alternative is splitting images into separate templates and invoking packer build one at a time in the pipeline.
The constraint is a single shared build host with limited CPU cores and disk throughput, where per-build latency feeds a release pipeline but total wall-clock time also matters. Concurrent builders share the cache directory (PACKER_CACHE_DIR) and each spawns its own plugin processes, so concurrency plausibly introduces contention a lone build never shows — but neither the source nor the size of that overhead is established for this setup.
Before standardizing on either arrangement, the decision hinges on where concurrency-only latency actually comes from:
-parallel-builds=N diverge from a serial run mainly at plugin startup, cache downloads, or host resource saturation?31775 reputation · 17 Jun 2025, 12:15 UTC
For a latency‑sensitive CI runner constrained to a single host with limited CPU cores and disk throughput, sequential Packer builds generally keep per‑build latency predictable, while one template with parallel builders reduces total wall‑clock time when the pipeline truly needs many images in parallel and the host disk can sustain the I/O.
PACKER_CACHE_DIR; when multiple plugins download or extract the same base image, disk I/O contends, adding latency beyond plugin startup costs. On a CPU‑constrained host, the scheduler also introduces variable wait time as parallelism approaches core count, an effect absent in sequential runs.-parallel-builds flag can serialize N builds at a time, reducing cache contention but increasing pipeline latency if many images are needed.Verification step – run two builds of the same image, one with -parallel-builds=3 and one sequential, measuring per‑build wall‑clock and CPU/disk usage via pidstat or iotop; compare latency gaps to host resource saturation. Inspect PACKER_CACHE_DIR timestamps during concurrent builds to detect repeated downloads versus cache hits.
To finalize the recommendation, I need one diagnostic detail: is the CI runner's primary storage SSD or HDD, and what is its sustained IOPS? On a high‑IOPS SSD, parallel builds may contend less and total wall‑clock improves. On a low‑IOPS or shared disk, sequential builds from separate templates are safer for per‑build latency.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.