Cold Starts and Autoscaling
Why a model takes time to wake up, how autoscaling adds copies, and the trade-off between idle cost and waiting, explained for your AI interview.
In short
A cold start is the wait while a new copy of a model loads before it can answer. Autoscaling adds or removes copies as traffic changes. Scaling to zero saves money, but the first requests then wait, so a team picks a minimum that fits its traffic and its wait limit.
14 min readIntermediateOccasional · estimateFacts checked 27 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
A cold start is the wait for a new copy of a model to load before it can answer. Autoscaling adds copies when traffic rises and removes them when it falls. For a large model the load takes longer, and the wait grows with the model's size, so scaling to zero saves money but makes the first users wait. I would keep a minimum of warm copies for the morning peak, cap the maximum to control cost, and scale on GPU use or, as a beta option, on pending requests.
A model runs on replicas, which are copies of the model, each running on GPU hardware. Autoscaling changes how many replicas run as traffic changes. The catch is the cold start: a new replica has to download the model weights, load them into GPU memory and get ready before it can answer. For a large model that takes longer, and the wait grows with the model's size. Each new copy must finish that load before it can take a single request.
Scaling to zero saves the most on idle hours. When nothing has arrived for a while, the platform removes every replica, so the quiet hours cost little. The price is paid by the first users of the morning, who wait for a replica to load, or get an error if the platform does not queue requests. Keeping one warm replica removes that wait, but a GPU that stays on all night still bills all night.
Autoscaling also lags. On Hugging Face, scale-up runs every minute, so a sudden spike can queue up before the new replica is ready. So I would keep a minimum warm before the spike, scale on GPU use or, as a beta option, on pending requests, cap the maximum so a bad day cannot run up the bill, and test the cold path with a real burst from zero.
What is a cold start, in plain words?
A model app runs copies of the model, called replicas. Each replica runs the model on GPU hardware, the fast chip that does the heavy maths. When traffic rises, the platform starts more replicas. When it falls, it stops some. That is autoscaling. Google's Cloud Run docs use the word instance for the same thing, so the two words mean the same here.
A cold start is the wait before a new replica can answer. Amazon's serverless service Lambda uses the same term: "When Lambda has to initialize a new environment to carry out an invocation, this is known as a cold start". A model replica pays the same kind of wait, and a longer one, because it has to load large weights first.
Think of a bank that opens an extra counter when the queue grows. The new clerk must sit down, log in and load the customer files before serving anyone. The first customers at that counter wait. A model replica does the same: it loads the weights before its first answer.
Key words
- Replica
- One running copy of the model, on GPU hardware.
- Weights
- The learned numbers that make up a model. They are the big files a replica must load.
- Cold start
- The wait while a new replica loads before it can answer.
- Scale to zero
- Stopping every replica when idle, to cut the bill.
- Minimum replicas
- How many always stay running, so the first request is not cold.
Why does loading a model take so long?
A new replica does three things before it can answer: it fetches the model files, loads the weights into GPU memory, and gets the runtime ready. Hugging Face, which hosts model endpoints, describes the first two: "During the initialization of a new replica, the model is downloaded and loaded into memory."
The wait also grows with the model. Hugging Face says that "The duration of the cold start period varies depending on your model's size." A bigger model means a longer wait before the first answer, so you can measure the cold start as a real cost.
What a cold start adds
New request
no replica is running yet
Cold start
Fetch the model
the files come from storage
Load into GPU
the weights fill GPU memory
Replica ready
now able to answer
Answer sent
the first user waited for this
- 1The first request finds no replica running.
- 2The platform downloads the model files.
- 3The weights are loaded into GPU memory before any answer.
- 4The ready replica answers, after the whole wait.
Tip
Cloud Run's GPU guide advises models that load fast. It also says: 'Your container can use the GPU as soon as the startup finishes.' Choosing the model format and where the files load from changes the cold start too.
What does a waiting user actually get?
It depends on the platform, and a good answer says so. Google's Cloud Run balances two waits. Its guide says that "Since on-demand scaling responds in real time to sudden traffic changes, Cloud Run manages the trade-off between cold start latency (the time to start a new instance) and pending queue latency (the time a request waits for a slot to open on an existing instance)". So some platforms hold the request and others fail it.
“Since on-demand scaling responds in real time to sudden traffic changes, Cloud Run manages the trade-off between cold start latency (the time to start a new instance) and pending queue latency (the time a request waits for a slot to open on an existing instance)”
Google Cloud Run
“after scaling in to zero instances, your endpoint can't respond to any incoming inference requests until it provisions at least one instance”
Amazon SageMaker
“there is currently no queueing system in place for incoming requests”
Hugging Face
Hugging Face's endpoints go a step further: the HTTP server "will respond with a status code 502 Bad Gateway while the new replica is initializing". With no queue on its side, the app needs its own retry queue and clear error messages for the user.
Should you scale to zero or keep one warm?
- Scale to zero
Cheapest at night
Nothing runs when idle, so the platform can stop billing it. Azure says you are not billed usage charges when an app scales to zero. The first requests of the morning pay the cold start.
- Keep one warm
Fastest first answer
The first request is never cold. The cost is a replica that stays loaded and bills while it sits idle.
Scale to zero or keep one warm
Scale to zero
Minimum 0
nothing runs while idle
Keep one warm
Minimum 1
one replica is always loaded
First requests wait
users pay the cold start
Answers at once
but the warm GPU bills while idle
- 1With no replica at night, the morning's first requests start a cold start.
- 2A warm replica answers at once, and its idle hours still cost money.
Cloud Run's GPU guide says that "minimum instances are charged at the full rate even when idle". Lambda's warm option also costs extra: "Configuring provisioned concurrency incurs additional charges to your AWS account". Warm capacity is a standing cost, so it should match a real need.
Some jobs do not need it. Lambda's guide says that "Asynchronous workloads, such as data processing pipelines, are often less latency sensitive and so do not usually need provisioned concurrency". A nightly batch can take a cold start, but a live claims screen cannot.
A made-up insurance firm runs a claims triage model. Claims start arriving at 09:00, and a replica takes a made-up 180 seconds to load. The script below counts how many of 14 early requests wait, under two settings.
# A made-up claims-triage model at 09:00. A replica takes 180 seconds to load (made-up).
# Simplified: one replica serves every request once it is ready, so only the cold wait is counted.
LOAD = 180
ARRIVALS = [0, 2, 5, 9, 14, 20, 30, 45, 60, 90, 120, 150, 200, 260] # seconds after 09:00
def waits(min_replicas):
ready = [0] * min_replicas # the second each replica can serve
result = []
for t in ARRIVALS:
if not ready:
ready.append(t + LOAD) # no replica at all: start loading now
result.append(max(0, min(ready) - t))
return result
for n in (0, 1):
w = waits(n)
print(f"min replicas {n}: {sum(x > 0 for x in w)} of {len(w)} requests waited, longest {max(w)} s")Output
min replicas 0: 12 of 14 requests waited, longest 180 s min replicas 1: 0 of 14 requests waited, longest 0 s
With scale to zero, 12 of the 14 requests wait, the longest three minutes. With one replica kept warm, none of these early requests wait for a cold start. A burst of many claims at once would still queue behind that one replica. The warm replica also runs through the night, which is the cost side of the same trade-off. The simplified script counts only the cold wait, so the real numbers depend on the platform and the traffic.
Tip
Ask one question first: does a person wait for this answer? If yes, plan warm capacity for those hours. If no, scale to zero and let the batch wait.
What should the autoscaler watch, and how fast does it react?
An autoscaler watches a signal and adds replicas when it crosses a target. On Hugging Face, the GPU rule is: "A new replica is added when the average GPU utilization of all replicas over a 1-minute window reaches 80%". The platform also offers a beta option based on pending requests, which include requests in progress. By default, a replica is added when there are more than 1.5 pending requests per replica in the past 20 seconds.
Reaction is slow for two reasons. Hugging Face says that "the scaling up process takes place every minute and scaling down takes place every 2 minutes", so a spike can build before anything new starts. The new replica then needs its own cold start before it helps. Scale-down is slower still: after each scale-down, a stabilisation period of 300 seconds keeps the count steady.
Why autoscaling arrives late
Morning spike
many claims in one minute
Requests queue up
no replica has spare room
Scaler adds a replica
checks run every minute on Hugging Face
Relief arrives late
after the new replica loads
- 1A burst of claims lands in one minute and piles up.
- 2The scaler sees the queue on its next check.
- 3The new replica helps only after its own cold start.
Cloud Run's guide lists the same settings: custom targets, and "setting minimum and maximum instance limits". The minimum keeps capacity ready. The maximum is a cost cap, so a bad day cannot run up the bill.
- 1
Set minimum replicas for the known peaks
Keep one or more warm through claim hours, so the morning spike lands on a ready replica.
- 2
Scale on the right signal
GPU use is the standard rule on Hugging Face. Pending requests is a beta option, so test it before you rely on it.
- 3
Cap the maximum
The maximum is a cost cap, sized to the peak you have measured.
- 4
Hold a queue if the platform has none
Hugging Face has no queue, so the app keeps its own retry queue and shows a clear message.
- 5
Test the cold path
Run a burst from zero, time the first answer, and check the bill for the warm hours.
How would you stop 9 am claims from waiting?
A claims team says the first ten minutes after 9 am are slow, but keeping a GPU warm all day is too expensive. Here is how I would approach it.
- 1
Measure first
Pull the start times, the queue length and the first-answer time for the last month.
- 2
Keep one replica warm during claim hours
Set the minimum to one from before 9 am until the queue is empty, then let it scale to zero overnight.
- 3
Warm up before the bell
A warm-up request sent a few minutes before 09:00 starts a replica before the first claim arrives.
- 4
Keep a ceiling
Set the maximum from the measured peak, so a surge cannot run up the bill.
- 5
Show the trade-off
Put the cost of the warm hours next to the waits saved, and let the business choose the balance.
What does the interviewer want to hear?
A strong answer covers
- A plain definition: the wait while a new replica loads.
- Why it is slow: model files and weights load into GPU memory.
- Scale to zero versus keep warm, with the cost of each.
- What a waiting user gets: a queue or an error, depending on the platform.
- Why autoscaling lags, and which signal you pick.
- How you would test it with a real burst from zero.
Common traps
Trap"Autoscaling fixes slow starts."
BetterIt adds copies, but each new copy still pays the cold start, so the spike can arrive first.
Trap"Scale to zero is always the cheapest."
BetterIt saves idle hours. Count what the first waits cost the users too.
Trap"Just add more GPUs."
BetterMore replicas cost more, and each one still starts cold. Warm the first one, then scale on the queue.
Can you spot the cold start?
Spot the cause
The claims team says the first minutes after 9 am are slow every day. Which setting is the cause?
Quick check
A model replica can take a long time to load, and the wait grows with model size. Which change most cuts the wait at the 9 am spike?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
Last updated on 27 November 2026
Running a model endpoint that must answer at a set time?
I design and build AI products and agents, including the system behind them. Book a short call and tell me your peak hours and how long a user can wait.