94.88% CI/CD Infrastructure Cost Reduction

Azure Batch Spot VMs Docker Unity Cost Optimization

Context: Unity CI/CD build environment isolation at VARLab

Problem: Unity Editor 100% CPU usage causing server crashes on concurrent builds

Solution: Azure Batch + Spot VMs for on-demand execution

Result: 94.88% infrastructure cost reduction ($618 → $32 for 56 days)

Cloud-Native Unity CI/CD Infographic

Key Achievements

MetricBeforeAfter
Build environmentShared CI/CD serverIsolated cloud containers
Concurrent buildsServer crash riskParallel execution safe
Cost model24/7 VM runningPay-per-use
Cost reduction-94.88%

Problem Evolution & Solutions

Phase 1: The Initial Crisis (June 2024)

Problem: Unity Editor provides no CPU usage control during builds. When 2+ projects build simultaneously, the CI/CD server crashes.

Root Cause Analysis:

Solution: Trade-off approach — maintain project files & artifacts (skip “from scratch” builds), set optimization level to 0 (skip optimization phase).

Result: Reduced initial compile time from 10 min → 1 min, prevented server crashes.

Trade-off Cost: Violated CI/CD best practice of “clean builds from scratch”

Phase 2: Containerization + Build Optimization (May 2025)

Goal: Eliminate the trade-off from Phase 1 — enable clean builds without sacrificing speed.

Solution 1: Docker containerization with CPU allocation — enabled concurrent builds without crashes.

Solution 2: PID-level profiling + Unity settings optimization — analyzed CPU usage at 5-second intervals, tuned emscriptenArgs, Il2CppCodeGeneration, managedStrippingLevel, etc.

MetricBeforeAfter
Clean build time13-14 min7.4 min (47% faster)
Build size146 MB95.2 MB (35% smaller)
PID-Level Profiling & Build Optimization (PDF)

Limitation: Still running on the same CI/CD server.

Phase 3: Cloud-Native Architecture (June 2025)

Proactive Initiative: Docker containerization in Phase 2 proved builds could run in isolated environments. This raised a question: if containers can run independently, why not leverage cloud infrastructure for parallel, on-demand execution?

Solution: Azure Batch + Spot VMs — completely separated Unity build/test environment from CI/CD server. On-demand ephemeral containers, pay only for actual compute time.

StrategyCost (56 days)vs Always-On
Always-On VM (24/7)$618.24baseline
Deallocated VM (job-triggered)$144.60-76.6%
Azure Batch + Spot VMs$31.64-94.88%
Cloud-Native Architecture & Cost Benchmarking (PDF)
Analysis Period: May 5 - June 29, 2025 (56 days, 37 active days) | Projects: 2 Unity VR projects (855 CI jobs, 166 CD jobs)

Architecture Comparison

Before: Coupled Architecture

CI/CD Server (VM)
Jenkins
Orchestration
Unity Editor
Build
CPU: 100% during builds

After: Decoupled Architecture

CI/CD Server
Jenkins
Orchestration
Lightweight
Azure Batch Pool
Spot VM Spot VM ...
On-demand, isolated

Additional Benefits