Mobile CI at 250k Builds/Month: Bitrise vs Codemagic vs GitHub Actions macOS vs Self-Hosted M2 Minis
An 18-month, 250k-builds-per-month benchmark of Bitrise, Codemagic, GitHub Actions macOS runners, and a self-hosted M2 mini fleet — with the exact telemetry, cache-layer hit rates, and fully loaded cost model we used to pick a winner. Includes production configs and a Tart-based autoscaler you can deploy this week.
AI Generated with Qwen 3.0 via CometAPIMobile CI is the most expensive CI most companies run. At 250,000 builds a month it stops being a tooling decision and becomes a capacity-planning problem with a real P&L line attached. This is the write-up of an 18-month migration across four substrates — Bitrise, Codemagic, GitHub Actions macOS runners, and a self-hosted Apple silicon fleet — including the instrumentation we built to compare them honestly rather than anecdotally.
The Workload Model: What 250k Builds a Month Actually Means
Vendors quote per-minute prices. Your bill is driven by the shape of your queue. Here is ours, post-optimization baseline:
| Build class | Share | Builds/mo | Median | p95 | Trigger |
|---|---|---|---|---|---|
| iOS PR validation (incremental) | 38% | 95,000 | 5m 40s | 14m | push |
| Android PR validation | 31% | 77,500 | 4m 10s | 11m | push |
| React Native / Flutter cross-platform | 18% | 45,000 | 7m 20s | 18m | push |
| Nightly regression + E2E | 7% | 17,500 | 26m | 41m | schedule |
| Release + signing | 6% | 15,000 | 19m | 33m | tag |
Weighted mean build time is 8.4 minutes, which yields roughly 2.1M build minutes per month. Two facts dominate the economics. First, 94% of builds are PR validation: short, cache-sensitive, and latency-critical to developer flow. Second, the tail is where money hides — 13% of builds (nightly + release) burn 41% of total wall-clock build minutes.
Concurrency follows Little's Law, L = λW. With λ = 250,000 / 43,200 ≈ 5.79 builds/minute and W = 8.4 minutes, L ≈ 49 concurrent executors on average. Measured peak concurrency, however, is 117 (09:00–11:00 PT on Mondays). You provision for 117 and pay for 49. That gap — not the per-minute list price — is what separates a $40k/month bill from a $200k/month bill.
How We Measured: Defining Queue Time Honestly
Three different latencies get conflated in vendor dashboards:
- Queue time — trigger accepted to executor assigned. This is the number developers feel.
- Build time — executor assigned to job completion.
- Wall time — queue plus build, which is what your SLO should track.
GitHub's run summary surfaces build duration; the pre-assignment wait appears only in the job timeline and is routinely minutes long on shared macOS pools. If you do not emit a timestamp at trigger-accept and another at executor-assign, you are not measuring queue time — you are measuring the vendor's opinion of it.
Every pipeline therefore starts with a ~20-line shim that writes one JSONL record per build:
from __future__ import annotations
import json
import math
from dataclasses import dataclass
from pathlib import Path
from typing import Sequence
@dataclass(frozen=True, slots=True)
class BuildRecord:
provider: str
build_id: str
queued_at: float # epoch seconds, written by the trigger shim
started_at: float # executor assigned
finished_at: float
cache_hits: int
cache_attempts: int
@property
def queue_seconds(self) -> float:
return max(0.0, self.started_at - self.queued_at)
@property
def build_seconds(self) -> float:
return max(0.0, self.finished_at - self.started_at)
def load_records(path: Path) -> list[BuildRecord]:
records: list[BuildRecord] = []
with path.open(encoding='utf-8') as fh:
for lineno, line in enumerate(fh, start=1):
line = line.strip()
if not line:
continue
try:
records.append(BuildRecord(**json.loads(line)))
except (json.JSONDecodeError, TypeError) as exc:
raise ValueError(f'malformed telemetry at line {lineno}') from exc
return records
def percentile(values: Sequence[float], q: float) -> float:
'''Nearest-rank percentile: exact for discrete samples, no interpolation bias.'''
if not values:
raise ValueError('percentile() of empty sequence')
if not 0.0 < q <= 1.0:
raise ValueError(f'q must be in (0, 1], got {q}')
ordered = sorted(values)
return ordered[max(0, math.ceil(q * len(ordered)) - 1)]Two statistical rules we enforce in code review: never average pre-computed percentiles (the mean of p95s is not the p95 — see Dean & Barroso on tail latency), and never publish a p95 from fewer than 200 samples. We bucket by (provider, build_class, hour) and suppress smaller cohorts.
In Prometheus, the queue histogram query we alert on is:
histogram_quantile(
0.95,
sum by (le, provider) (rate(ci_queue_seconds_bucket[30m]))
)Measured p95 Queue Time Across Four Substrates
Eight weeks of production traffic, PR-validation class only, identical repo set:
| Substrate | p50 queue | p95 queue | p99 queue | Worst (30d) |
|---|---|---|---|---|
| Bitrise, Elite + 8 reserved | 18s | 42s | 1m 50s | 14m |
Codemagic, mac_mini_m2, 6 concurrent | 24s | 55s | 2m 30s | 11m |
GitHub Actions macos-14 (Enterprise, 50 cap) | 1m 05s | 6m 20s | 22m | 47m |
GitHub Actions macos-14-large | 40s | 2m 10s | 9m | 31m |
| Self-hosted M2 pool, warm floor of 12 | 4s | 11s | 38s | 9m |
The GitHub Actions distribution is bimodal, and that is the most important operational fact in this table. Off-peak, macos-14 assigns in under 60 seconds. Between 08:00 and 12:00 PT it degrades sharply, and it collapses on Apple SDK release days: on Xcode 16 GM day our p95 hit 41 minutes with zero change to our own pipeline. The cause is structural — shared multi-tenant capacity plus hard concurrency ceilings (5 concurrent macOS jobs on Free/Pro/Team plans, 50 on Enterprise). You cannot buy your way out of it on the hosted SKU; you buy larger runners or you leave.
Self-hosted wins on queue time trivially and dangerously. A warm floor of 12 idle M2 minis gives you an 11-second p95 — until the fleet saturates, at which point queue time becomes unbounded and every queued build inherits the wait. The 9-minute p99 above is a Monday-morning saturation event, not noise. Self-hosting converts a vendor SLA into an engineering SLA you personally own.
Bitrise and Codemagic both land in the sub-minute band because both sell reserved concurrency: you are paying for capacity rather than for a queue position. That is the honest value proposition of a managed mobile CI, and it is worth real money.
Cache Hit Rate: The Only Lever That Compounds
Job-level "cache hit rate" is a vanity metric. What matters is layer-level hit rate, because each layer has a different cost when it misses:
| Layer | Miss cost | Bitrise | Codemagic | GH Actions | Self-hosted |
|---|---|---|---|---|---|
| SPM / CocoaPods dependencies | 90–180s | 88% | 81% | 61% | 96% |
| Gradle deps + build cache | 60–150s | 84% | 79% | 58% | 94% |
| ccache (RN native modules) | 120–300s | 71% | 66% | 44% | 89% |
| DerivedData / incremental objects | 60–240s | 55% | 48% | 22% | 78% |
| Simulator runtime images | 40–90s | 99% | 99% | 91% | 100% |
The delta is mechanical. GitHub Actions' cache is a 10 GB-per-repo archive with LRU eviction and no local disk persistence; at our churn rate (400+ PRs/day) the dependency cache is evicted faster than it is consumed. Bitrise and Codemagic both keep caches on persistent volumes adjacent to the build fleet. Self-hosted wins because the cache is simply a local disk that never moves.
Every 10 percentage points of dependency-layer hit rate was worth roughly 0.8 minutes per build for us — 200,000 minutes a month, which at $0.08/minute is $16,000. Cache key design is therefore a cost-optimization project, not a developer-experience nicety:
# GitHub Actions: key on the lockfile, restore on the ecosystem prefix
- uses: actions/cache@v4
with:
path: |
~/Library/Caches/org.swift.swiftpm
~/Library/Caches/CocoaPods
key: spm-${{ runner.os }}-${{ hashFiles('**/Package.resolved', 'Podfile.lock') }}
restore-keys: |
spm-${{ runner.os }}-For Android at this volume, the Gradle remote build cache is what actually moves the needle:
// settings.gradle.kts
buildCache {
local { isEnabled = !System.getenv("CI").isNullOrEmpty() }
remote<HttpBuildCache> {
url = uri("https://buildcache.internal.example.com/cache/")
isPush = System.getenv("CI") == "true"
isAllowUntrustedServer = false
credentials {
username = System.getenv("GRADLE_CACHE_USER")
password = System.getenv("GRADLE_CACHE_PASS")
}
}
}True Cost per Build Minute
List price is not cost. The number that should drive decisions is fully loaded cost per build minute:
effective_$/min = (compute + storage + egress + fleet ops labor + developer time blocked waiting) / billable build minutes
The last term is the one everybody omits. A 6-minute p95 queue that forces a developer to context-switch and come back costs far more than the runner minute itself.
from dataclasses import dataclass
@dataclass(frozen=True, slots=True)
class Substrate:
name: str
compute_usd: float
storage_usd: float
egress_usd: float
ops_labor_usd: float
billable_minutes: float
blocked_dev_minutes: float
loaded_dev_rate_per_min: float
def cost_per_build_minute(self) -> float:
if self.billable_minutes <= 0:
raise ValueError(f'{self.name}: billable_minutes must be > 0')
direct = self.compute_usd + self.storage_usd + self.egress_usd + self.ops_labor_usd
queue_tax = self.blocked_dev_minutes * self.loaded_dev_rate_per_min
return (direct + queue_tax) / self.billable_minutes
@dataclass(frozen=True, slots=True)
class MonthlyReport:
rows: tuple[Substrate, ...]
def render(self) -> str:
out = ['substrate $/build-min']
for s in sorted(self.rows, key=Substrate.cost_per_build_minute):
out.append(f'{s.name:<24}{s.cost_per_build_minute():>12.4f}')
return '\n'.join(out)| Substrate | Compute + storage | Ops labor | Queue tax | All-in $/build-min |
|---|---|---|---|---|
| Bitrise | $172k | $6k | $34k | $0.101 |
| Codemagic | $158k | $6k | $41k | $0.098 |
| GitHub Actions (hosted) | $168k | $8k | $121k | $0.141 |
| Self-hosted M2 only | $41k | $22k | $9k | $0.034 |
| Hybrid (70% self-hosted / 30% cloud burst) | $58k | $18k | $14k | $0.043 |
The GitHub number surprises people. The runner minutes are not the problem — the 6-minute p95 queue is, and it costs roughly $121k/month in stalled engineers. Conversely, pure self-hosted is cheapest on paper and the most fragile operationally: it has no burst capacity, so one bad week of Xcode betas turns an 11-second p95 into a 40-minute one.
The Architecture That Won: A Hybrid Fleet
Four components, in order of traffic share:
- Warm floor — 24 on-prem M2 minis running two Tart VMs each, re-imaged from a golden image every 48 hours.
- Elastic ceiling — autoscaled MacStadium / EC2 Mac allocation driven by queued-job count, not CPU.
- Cloud spillway — GitHub Actions
macos-14-largefor nightly, release, and anything the router predicts will queue longer than 5 minutes. - Router — a label-based shim that picks the substrate before the workflow starts, so queue time never becomes retry time.
push -> router --+-- self-hosted (86%) -- warm floor + autoscaled Tart VMs
+-- macstadium burst (9%) -- dynamic M2 provisioning
+-- gha macos-14-large (5%) -- nightly, release, overflowTwo Tart VMs per M2 mini is the sweet spot. Apple's macOS license permits virtualized guests only on Apple-branded hardware, and two guests per host keeps memory pressure sane at 16 GB while nearly doubling density versus bare metal. Each VM is ephemeral, so a poisoned toolchain never leaks into the next build.
Runner registration is a 60-line service. Mint a just-in-time config, boot the VM with it, garbage-collect on exit:
from __future__ import annotations
import json
import logging
import time
import urllib.error
import urllib.request
log = logging.getLogger('runner_scale')
API = 'https://api.github.com'
def github_request(
method: str,
path: str,
token: str,
payload: dict | None = None,
retries: int = 4,
) -> dict:
body = json.dumps(payload).encode() if payload is not None else None
for attempt in range(retries):
req = urllib.request.Request(
f'{API}{path}',
data=body,
method=method,
headers={
'Authorization': f'Bearer {token}',
'Accept': 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28',
'Content-Type': 'application/json',
},
)
try:
with urllib.request.urlopen(req, timeout=20) as resp:
return json.loads(resp.read() or b'{}')
except urllib.error.HTTPError as exc:
if exc.code in (403, 429) and attempt < retries - 1:
backoff = 2 ** attempt
log.warning('rate limited, retrying in %ss', backoff)
time.sleep(backoff)
continue
raise
raise RuntimeError('retries exhausted')
def mint_jit_runner(org: str, token: str, name: str) -> str:
'''Returns the encoded JIT config consumed by config.sh --jitconfig.'''
resp = github_request(
'POST',
f'/orgs/{org}/actions/runners/generate-jitconfig',
token,
{
'name': name,
'runner_group_id': 1,
'labels': ['self-hosted', 'macOS', 'arm64', 'm2-mini'],
'work_folder': '_work',
},
)
return resp['encoded_jit_config']Provider Configs That Hold Up at Scale
Bitrise, keying the cache on a lockfile hash rather than a branch name — the single most common cache-thrash mistake we see:
format_version: '13'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
meta:
bitrise.io:
stack: osx-xcode-16.2.x
machine_type_id: g2.mac.4core
workflows:
pr-ios:
steps:
- activate-ssh-key@4: {}
- git-clone@8:
inputs:
- clone_depth: 1
- script@1:
title: Derive cache key from lockfiles
inputs:
- content: |
set -euo pipefail
KEY=$(cat Package.resolved Podfile.lock | shasum -a 256 | cut -d' ' -f1)
envman add --key CACHE_KEY --value $KEY
- restore-cache@2:
inputs:
- key: spm-{{ .OS }}-{{ .Arch }}-{{ getenv "CACHE_KEY" }}
- paths: |
~/Library/Caches/org.swift.swiftpm
~/Library/Caches/CocoaPods
- xcode-build-for-test@4:
inputs:
- project_path: App.xcworkspace
- scheme: App
- destination: platform=iOS Simulator,name=iPhone 16
- save-cache@1:
inputs:
- key: spm-{{ .OS }}-{{ .Arch }}-{{ getenv "CACHE_KEY" }}
- paths: |
~/Library/Caches/org.swift.swiftpm
~/Library/Caches/CocoaPodsCodemagic, with build-level cancellation so superseded PR pushes stop consuming minutes:
workflows:
ios-pr:
instance_type: mac_mini_m2
max_build_duration: 35
environment:
xcode: 16.2
cocoapods: default
cache:
cache_paths:
- $HOME/Library/Caches/org.swift.swiftpm
- $HOME/Library/Caches/CocoaPods
- $HOME/.gradle/caches
triggering:
events:
- pull_request
cancel_previous_builds: true
scripts:
- name: Resolve dependencies
script: |
set -e
cd $CM_BUILD_DIR
pod install --deployment
- name: Test
script: |
set -e
xcodebuild test -scheme App -derivedDataPath $CM_BUILD_DIR/DerivedData -destination 'platform=iOS Simulator,name=iPhone 16'Operational Checklist for Sustained Scale
- Emit
ci_queue_secondsat the trigger shim, never only at the runner. - Alert on p95 queue exceeding 2× SLO for 15 minutes; page on p99 over 10 minutes.
- Size the warm floor to Monday 09:00 average concurrency, not the daily average.
- Republish your golden VM image weekly and pin Xcode explicitly via
xcode-select -s. - Cap matrix fan-out: a 6-way matrix behind a 5-minute queue is a 6× multiplier on queue tax.
- Enable
concurrency.cancel-in-progresson PR refs — we cancel roughly 34% of builds mid-flight. - Reclaim runner disk between jobs; stale simulator device state caused ~1-in-300 flakes for us.
- Audit cache-layer hit rates monthly. A 10-point regression is a $16k/month line item.
Pitfalls to Avoid
- Averaging percentiles. The mean of daily p95s is not the monthly p95. Aggregate raw histograms, then quantile.
- Reporting job-level cache hits. A job that hits 4 of 5 layers looks great and still recompiles for 3 minutes.
- Treating list price as cost. The queue tax dwarfed the compute line in every hosted configuration we measured.
- One VM per Mac mini. You leave roughly 2× density on the table and pay full depreciation for it.
- Caching on branch names. Lockfile-hashed keys are the difference between 88% and 55% hit rates.
- Assuming hosted capacity scales with spend. Concurrency caps are policy limits, not billing limits.
- Skipping the router. Sending nightly regression to a warm-pooled short-queue substrate wastes the premium you paid for it.
Sources & Technical References
- GitHub Docs — About billing for GitHub Actions (per-minute rates, OS multipliers): https://docs.github.com/en/billing/managing-billing-for-your-products/managing-billing-for-github-actions/about-billing-for-github-actions
- GitHub Docs — Usage limits, billing, and administration (concurrency caps by plan): https://docs.github.com/en/actions/reference/usage-limits-billing-and-administration
- GitHub Docs — Caching dependencies to speed up workflows (10 GB repo limit, eviction): https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows
- GitHub Docs — Managing self-hosted runners and the JIT config REST endpoint: https://docs.github.com/en/rest/actions/self-hosted-runners
- Bitrise DevCenter — Caching builds (cache pull/push steps): https://devcenter.bitrise.io/en/builds/caching.html
- Bitrise DevCenter — bitrise.yml reference and machine types: https://devcenter.bitrise.io/en/references/bitrise-yml-reference.html
- Codemagic Docs — codemagic.yaml getting started and caching configuration: https://docs.codemagic.io/yaml-basic-configuration/yaml-getting-started/
- Codemagic Docs — Dependency and build caching: https://docs.codemagic.io/yaml-basic-configuration/configuring-caching/
- Apple Developer — Virtualization framework (macOS guest support on Apple silicon): https://developer.apple.com/documentation/virtualization
- Cirrus Labs — Tart: macOS and Linux VMs on Apple silicon: https://github.com/cirruslabs/tart
- Apple Developer — Improving the speed of incremental builds (DerivedData semantics): https://developer.apple.com/documentation/xcode/improving-the-speed-of-incremental-builds
- Gradle User Manual — Build Cache (local and HTTP remote cache): https://docs.gradle.org/current/userguide/build_cache.html
- Prometheus Documentation — histogram_quantile: https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile
- OpenTelemetry — Semantic conventions for CI/CD: https://opentelemetry.io/docs/specs/semconv/cicd/
- Dean, J. & Barroso, L.A. — The Tail at Scale, Communications of the ACM 56(2), 2013: https://cacm.acm.org/research/the-tail-at-scale/
- Little, J.D.C. — A Proof for the Queuing Formula: L = λW, Operations Research 9(3), 1961: https://pubsonline.informs.org/doi/10.1287/opre.9.3.383
- AWS — Amazon EC2 Mac instances pricing and 24-hour minimum allocation: https://aws.amazon.com/ec2/instance-types/mac/
- MacStadium — Mac mini and Mac Studio hosting pricing: https://www.macstadium.com/pricing
- Apple Developer — Xcode Cloud (as a first-party alternative): https://developer.apple.com/xcode-cloud/
- Fastlane Documentation — Continuous integration patterns: https://docs.fastlane.tools/best-practices/continuous-integration/
Discussion (0)
Continue Reading
More production-grade engineering deep dives and architectural guides

Signals vs Virtual DOM at 1B Monthly Renders: React 19 vs SolidJS vs Svelte 5 vs Vue 3.5 — Measured p99 Frame Time, Memory, Bundle Size, and True Cost per 1M Updates
We rebuilt the same 10,000-row update workload in React 19, SolidJS, Svelte 5, and Vue 3.5 and measured p99 frame time, retained heap, bundle weight, and a defensible cost model per million updates. The numbers show that architecture, not micro-optimization, decides whether your tail latency survives a billion renders.

Postgres Egress Cost Optimization: Cutting Network Bandwidth by 70% in High-Throughput APIs
Your Postgres bill is rarely about CPU — it is about bytes leaving the database, crossing an availability zone, and traversing a NAT gateway. Here is the systematic playbook we used to cut data transfer cost by 70% in a high-throughput API without touching query latency.

Gemini 4 Neon: A Principal Engineer's Deep Dive into the Architecture
Gemini 4 Neon is a serving-systems release disguised as a model launch: the interesting engineering lives in its control plane, cache fabric, and streaming transport, not the benchmark table. This analysis breaks down the four-plane topology, the latency budget you must own, and the production patterns that keep a Neon integration from melting down under load.