Cold start triggers
Every new replica cold-starts before it can serve traffic, no matter why it was created. Scale-from-zero applies when a deployment’smin_replica is 0. After traffic drops, the autoscaler waits for scale_down_delay, removes replicas up to max_scale_down_rate, and resets the delay. It repeats these steps until no replicas remain. A synchronous request can then trigger a replica startup and wait for it to finish.
Scaling events happen while a deployment is already serving traffic. When load crosses the scaling threshold, the autoscaler adds replicas, and each one cold-starts before it can serve traffic. The replicas already running keep serving in the meantime, so users notice only when load grows faster than new replicas can start up.
Contributing factors
A new replica works through these steps in order, and their durations add up to the cold-start time:
Baseten provides the Baseten Delivery Network (BDN), which speeds up weight load by mirroring your weights and caching them near your replicas. Each scale-up can read the weights from that cache instead of downloading them again from the source. Baseten also streams your container image in the background so image transfer can overlap other startup work.
The dominant step depends on the model, runtime, and hardware. Engine initialization can dominate when graph capture or compilation is substantial. Weight loading can dominate when the model has larger weight files. Benchmark your deployment to identify the step to optimize.
Reduce cold starts
The biggest win comes from shrinking whichever step dominates startup. When that isn’t enough, keep replicas warm so requests skip the cold start entirely.Faster weight loading
BDN runs automatically on engine-builder deployments. On any other deployment, turn it on by adding aweights block to your config.
Compilation caching
torch.compile creates artifacts while a replica starts. Torch compile caching, built on b10cache, persists those artifacts so a new replica can reuse them instead of compiling from scratch. Benchmark your deployment to measure the effect on startup time.
Warm replicas
min_replica sets a floor on running replicas. Keep it at 1 or higher so a replica stays warm to serve the first request. You pay for that replica while it’s idle, but requests avoid a scale-from-zero wait or rejection. Set it in the dashboard or through the autoscaling settings API:
Autoscaling settings
min_replica to 2 or higher so another warm replica remains available while Baseten replaces a failed or restarting replica.
Your replica floor trades cost against latency:
Start warm for production, and scale to zero only when an occasional cold-start wait or retry is acceptable.
Pre-warming
For predictable traffic spikes, raisemin_replica ahead of the expected load:
Terminal
Scale-down delay
A longer scale-down delay keeps replicas warm through brief traffic dips. The default is 15 minutes (900 seconds); this example doubles it to 30 minutes:Autoscaling settings
Next steps
- Request lifecycle: What happens to requests during cold starts, including queuing and timeout behavior.
- Autoscaling: Configure
min_replica,scale_down_delay, and the rest of the scaling settings. - Traffic patterns: Pre-warming strategies for different traffic types.
- Billing and usage: How cold-start time is metered.
- Troubleshooting: Diagnose cold start issues.