Deploy times under 30 seconds: how we did it
Parallel image pulls, pre-warmed containers, and edge caching — the technical breakdown.
When we launched CodeHost, deploys took 45 seconds on average. That was fine — competitive with most platforms. But we wanted under 30. Here's the engineering breakdown of how we got there.
The deploy pipeline
A deploy on CodeHost goes through four stages: image pull, container create, network configure, and health check. The breakdown when we started: 22s image pull, 8s container create, 6s network, 9s health check. Total: 45s.
Optimization 1: Pre-warmed image cache
Most of the image pull time was spent downloading layers that hadn't changed since the last deploy. We introduced a regional image cache that pre-pulls the latest version of every library app into every edge region. When you deploy, the image is already local. Pull time dropped from 22s to 3s.
Optimization 2: Parallel container setup
Container creation was sequential: allocate resources, mount volumes, inject env vars, start process. We parallelized the independent steps — volume mounting and env injection now run concurrently. Container create dropped from 8s to 4s.
Optimization 3: Pre-configured networking
Network configuration — assigning an IP, setting up DNS, provisioning the SSL certificate — used to happen after the container started. We moved to a model where network resources are pre-allocated when you first add a domain. Deploy-time network config dropped from 6s to 2s.
Optimization 4: Fast health checks
Health checks waited 10s between retries. We switched to a TCP-level check that detects a listening port immediately, then does a single HTTP check to verify the app is responding. Health check time dropped from 9s to 4s.
Final pipeline: 3s pull + 4s container + 2s network + 4s health = 13s. With variance, p95 is 28s.
What's next
We're experimenting with snapshot-based deploys — pre-building a running container snapshot and restoring it on deploy, skipping the container creation and health check entirely. Early results show sub-5s deploys. Stay tuned.