Planning GPUs: utilization target, workload consolidation, interruptible instances and priority queues
A GPU costs money for every hour you hold it, whether you use it or not, and the planning question always comes in the same three forms: how much capacity to keep free, how many workloads to put on the same card, and whether to accept a machine that can vanish halfway through the job in exchange for a lower price. The answer of this article is that none of the three has a right value in absolute terms: the utilization target depends on how long you are willing to wait in a queue, consolidation depends on how synchronized the peaks of your workloads are, and interruptible instances only pay off with a well-chosen checkpoint. Every point has an executed listing, with computing models and parameters that are invented and declared as such: no GPU was used.
The choice between your own server and an API is covered in the comparison of self-hosting and APIs, and I do not repeat it here: the starting point is that you have already decided to run accelerators, rented or bought, and the question is how to use them. The techniques that reduce tokens and the memory required, and therefore change how many cards you need, are in the article on optimization techniques.
What "utilization" of a GPU means
The number that nvidia-smi shows as GPU utilization does not measure how much computing capacity you are using. The tool's documentation defines it as the percentage of time, over the last sampling period, during which one or more kernels were executing on the card, with a period between one second and one sixth of a second depending on the product. A card that always has a small kernel running shows 100% while using a fraction of its compute units. A target such as "75% utilization" read from that counter therefore tells you how long the card is busy, not how much more work it could do.
To decide on capacity you need several measurements, and none of them replaces the others:
- The time the card spends executing kernels, from the
nvidia-smicounter. - The work served, for example tokens or requests per second, compared with the capacity you measured at saturation with a test load.
- The memory in use, which is often the real constraint before compute is.
- The queueing delay of the requests, which is what the user sees.
The second is the closest to the idea of "capacity used", but it requires a measurement at saturation that no counter gives you: it has to be taken with a controlled load. The fourth is the most honest, because it connects the card to the service. Two practical limits come from the NVIDIA documentation: on GPUs with MIG enabled, querying compute and memory utilization is currently not supported, and with time-slicing the DCGM-Exporter does not associate the metrics with individual containers. If you plan to share cards, decide in advance how you will measure each workload.
Why not aim for 100%: the wait grows without bound
When requests arrive at random and the work per request varies, a queue forms even on a card that is free on average, and its length grows non-linearly with utilization. The classic M/M/c queueing model (Poisson arrivals, exponential service times, c identical servers) describes it with the Erlang C formula. The first listing applies it to 1, 4 and 16 accelerators and measures the mean wait in units of service time. It is a textbook model: the service times of language models have a longer tail than the exponential, so real waits are higher, and the listing should be read as a lower bound.
"""Why you aim for 70-80% utilization and not 100%: the queueing delay grows without bound towards 100%.
M/M/c queueing model (Poisson arrivals, exponential service, c identical accelerators): Erlang C formula.
It is a TEXTBOOK model, not a measurement: real models have a longer service-time tail, so real waits
are HIGHER than these. Mean service time: 1 unit (waits are multiples of the service time)."""
from math import factorial
def attesa_media(c, rho):
"""Mean queueing wait, in units of service time. rho = mean utilization of each of the c servers."""
a = c * rho # offered load, in 'busy servers'
termine = a**c / (factorial(c) * (1 - rho))
p_attesa = termine / (sum(a**k / factorial(k) for k in range(c)) + termine) # prob. that an arrival has to wait
return p_attesa / (c * (1 - rho))
print(f"{'utilization':>11s} {'1 server':>10s} {'4 servers':>10s} {'16 servers':>10s} (mean queueing wait / service time)")
for rho in (0.5, 0.7, 0.8, 0.9, 0.95, 0.99):
print(f"{rho:11.0%} " + " ".join(f"{attesa_media(c, rho):10.2f}" for c in (1, 4, 16)))
# Output:
# utilization 1 server 4 servers 16 servers (mean queueing wait / service time)
# 50% 1.00 0.09 0.00
# 70% 2.33 0.36 0.03
# 80% 4.00 0.75 0.10
# 90% 9.00 1.97 0.37
# 95% 19.00 4.46 0.98
# 99% 99.00 24.45 5.96
With a single server the mean wait equals the service time at 50% utilization, is 4 times the service time at 80%, 9 times at 90% and 99 times at 99%. With four servers, at the same 80%, the wait drops to 0.75 times the service time, and with sixteen to 0.10: putting more servers behind the same queue lets you keep them busier for the same wait. The practical consequence is twofold. First, a 70-80% target is not a magic rule: for a single card, between 50% and 80% the mean wait goes from one to four times the service time, and your threshold depends on the wait the service tolerates. Second, with a single card it pays to leave more margin than a fleet of sixteen needs: spare capacity is a cost that is better spread over many servers.
Consolidating workloads: two techniques, one trade-off
If you have small workloads, one per card is a waste, and Kubernetes alone does not help: its documentation says that GPUs are specified only in limits, that you can give the limit without the request (the limit is then used as the request), and that if both figures appear they must be equal. The NVIDIA documentation adds that a typical request gives exclusive access to the GPUs: without a sharing configuration the pod takes the whole card. The two techniques for sharing are documented by NVIDIA. Time-slicing, through the GPU Operator, defines a set of replicas for each GPU, each assignable to a pod, and the workloads take turns over time: the documentation specifies that, unlike MIG, there is no memory or fault isolation between replicas. MIG (Multi-Instance GPU) partitions supported cards into isolated instances, each with dedicated compute and memory and guaranteed performance, and the documentation notes that the two techniques can also be combined.
The trade-off is between density and isolation. The second listing shows the density side: six invented workloads with memory, normal utilization and peak utilization, packed with the first-fit decreasing algorithm on 24 GB cards, under three admission rules. A fixed-seed simulation estimates for how much of the time the worst group exceeds 100% of the card, assuming that the workloads' peaks are independent, which in reality may not be true.
"""Consolidating several workloads on the same accelerator: the packing policy decides how many cards you need
and for how long the card is overloaded. INVENTED workloads; fixed-seed simulation. No GPU used."""
import random
MEMORIA_GPU = 24.0
# (name, memory GB, normal utilization, peak utilization, probability of a peak at any instant)
CARICHI = [
("chat", 10.0, 0.30, 0.80, 0.15),
("summaries", 6.0, 0.15, 0.50, 0.10),
("embedding", 3.0, 0.10, 0.40, 0.10),
("agent", 8.0, 0.20, 0.70, 0.20),
("evaluations", 5.0, 0.10, 0.60, 0.05),
("tests", 4.0, 0.05, 0.30, 0.05),
]
def impacchetta(ammesso):
"""First-fit decreasing by memory. 'ammesso(group)' decides whether the group is acceptable beyond memory."""
gpu = []
for c in sorted(CARICHI, key=lambda x: -x[1]):
for g in gpu:
if sum(x[1] for x in g) + c[1] <= MEMORIA_GPU and ammesso(g + [c]):
g.append(c); break
else:
gpu.append([c])
return gpu
def tempo_sovraccarico(gruppo, passi=20000, seme=1):
rng = random.Random(seme)
sopra = 0
for _ in range(passi):
domanda = sum(c[3] if rng.random() < c[4] else c[2] for c in gruppo)
sopra += domanda > 1.0
return sopra / passi
politiche = {
"sum of peaks <= 100%": lambda g: sum(c[3] for c in g) <= 1.0,
"normals + 1 peak <= 100%": lambda g: sum(c[2] for c in g) + sum(sorted((c[3] - c[2] for c in g), reverse=True)[:1]) <= 1.0,
"sum of normals <= 70%": lambda g: sum(c[2] for c in g) <= 0.70,
}
for nome, regola in politiche.items():
gpu = impacchetta(regola)
peggiore = max(tempo_sovraccarico(g) for g in gpu)
print(f"{nome:26s} cards: {len(gpu)} overload of the worst group: {peggiore:6.2%} of the time")
for g in gpu:
print(" ", ", ".join(c[0] for c in g), f"({sum(c[1] for c in g):.0f} GB)")
# Output:
# sum of peaks <= 100% cards: 4 overload of the worst group: 0.00% of the time
# chat (10 GB)
# agent, tests (12 GB)
# summaries, embedding (9 GB)
# evaluations (5 GB)
# normals + 1 peak <= 100% cards: 2 overload of the worst group: 3.03% of the time
# chat, agent (18 GB)
# summaries, evaluations, tests, embedding (18 GB)
# sum of normals <= 70% cards: 2 overload of the worst group: 31.95% of the time
# chat, agent, summaries (24 GB)
# evaluations, tests, embedding (12 GB)
The prudent rule, which sums the peaks, requires 4 cards and never overloads. The intermediate rule, which sums the normal utilizations plus the largest peak, requires 2 and exceeds capacity 3.03% of the time; the rule that looks only at the sum of the normals also requires 2 but overloads the worst group almost a third of the time (31.95%). The number that decides is the cost of overload: for a batch workload a few percentage points of time over capacity are irrelevant, while for an interactive service they become queueing delay. The listing does not model shared memory: with time-slicing a replica that consumes more memory than expected can make the others fail too, which is why in that case memory must be sized on the sum of the peaks, not on the average.
Interruptible instances: the low price pays off only with a well-chosen checkpoint
Some providers sell surplus capacity at a much lower price, with the option to take it back at any moment. The Google Cloud documentation on Spot VMs, taken as an example of a provider, declares discounts of up to 91% for many machine types, GPUs included, and specifies that the service may preempt or delete the machines at any time and that they should be used for fault-tolerant workloads, such as batch jobs or stateless services. The "up to" is part of the sentence: the discount you get depends on machine type, region and time, and should never be assumed.
The third listing models a job of 10 hours of compute with an interruption on average every 5 hours and a spot price at 40% of on-demand. Saving the state costs 3 minutes, restarting 6 minutes, and each interruption loses the work done since the last checkpoint. The function una_prova simulates the sequence of blocks of work, each followed by a checkpoint, with a random interruption that can fall at any point; the interval between checkpoints is the only parameter that changes between rows.
"""Interruptible (spot) instances: the low price pays off only if an interruption does not throw away the work done.
A job of 10 hours of compute, Poisson interruptions (one every 5 hours on average), spot price at 40% of on-demand:
all parameters are INVENTED. Fixed seed, 3000 trials per row. The cost is relative to 10 hours on-demand (= 1.00)."""
import random
from statistics import mean
LAVORO, MTBF, PREZZO_SPOT = 10.0, 5.0, 0.40
COSTO_CHECKPOINT, RIAVVIO = 0.05, 0.10 # hours to save a state; hours to restart after an interruption
def una_prova(rng, intervallo):
"""Total wall-clock hours to complete the job with a checkpoint every 'intervallo' hours of useful work."""
fatto, durata = 0.0, 0.0
while fatto < LAVORO:
passo = min(intervallo, LAVORO - fatto)
t_blocco = passo + (COSTO_CHECKPOINT if fatto + passo < LAVORO else 0.0)
guasto = rng.expovariate(1 / MTBF)
if guasto >= t_blocco:
durata += t_blocco; fatto += passo # the block and its checkpoint are done
else:
durata += guasto + RIAVVIO # the block in progress is lost
return durata
print(f"{'checkpoint every':>16s} {'mean hours':>10s} {'spot cost':>11s} (on-demand = 1.00)")
for intervallo in (0.1, 0.5, 1.0, 2.0, 5.0, 10.0):
rng = random.Random(42)
ore = mean(una_prova(rng, intervallo) for _ in range(3000))
etichetta = f"{intervallo:g} h" + (" (never)" if intervallo == LAVORO else "")
print(f"{etichetta:>16s} {ore:10.1f} {ore * PREZZO_SPOT / LAVORO:11.2f}")
# Output:
# checkpoint every mean hours spot cost (on-demand = 1.00)
# 0.1 h 15.5 0.62
# 0.5 h 11.8 0.47
# 1 h 11.9 0.47
# 2 h 12.9 0.51
# 5 h 17.6 0.70
# 10 h (never) 33.1 1.32
Without a checkpoint the mean wall-clock time is 33.1 hours and the cost, at spot price, is 1.32 times that of 10 on-demand hours: the "saving" becomes a larger expense. With a checkpoint every half hour or every hour the cost drops to 0.47, about half of on-demand, and the minimum falls between the two rows. Checkpoints that are too frequent cost again (0.62 at every 6 minutes, because saving takes up a growing share of the time) and checkpoints that are too rare bring the problem back (0.70 at every 5 hours). From this you get the rule of choice: the best interval balances the cost of saving against how much work you are willing to lose, and it depends on the mean time between interruptions. For an interactive service, where no checkpoint saves the response the user is waiting for, interruptible instances are not suitable; for a nightly evaluation or an indexing job, they are.
A queue with priorities and preemption
When you share a few cards between interactive workloads and long ones, a simple queue (first come, first served) makes a user wait behind a two-hour job. The fourth listing compares two policies on seven hand-written jobs, two cards and two classes: with the first, jobs are served in order of arrival; with the second, an interactive job in the queue makes a running batch job get interrupted, and the batch restarts from zero because it has no checkpoint. The comparison is not random: the jobs are the same in both cases, and the outputs are determined by the sequence.
"""A queue with priorities and preemption for two accelerators: interactive jobs do not wait for long jobs.
SCRIPTED jobs (no randomness): (arrival in minutes, duration in minutes, class, name). Class 0 = interactive, 1 = batch.
Policies: FIFO without preemption; priority with preemption (the interrupted batch job restarts from zero: no checkpoint)."""
import heapq
GPU = 2
LAVORI = [
(0, 120, 1, "batch-A"), (0, 120, 1, "batch-B"), (10, 5, 0, "chat-1"), (20, 5, 0, "chat-2"),
(30, 5, 0, "chat-3"), (130, 90, 1, "batch-C"), (140, 5, 0, "chat-4"),
]
def simula(prelazione):
t, coda, in_corso, fine, rifatti = 0, [], {}, {}, 0
futuri = sorted(LAVORI)
while futuri or coda or in_corso:
while futuri and futuri[0][0] <= t:
a, d, k, n = futuri.pop(0)
heapq.heappush(coda, ((k if prelazione else 0), a, n, d, k)) # without preemption everyone has the same priority
# preemption: an interactive job in the queue frees a slot by sacrificing a running batch job
if prelazione:
while coda and coda[0][4] == 0 and len(in_corso) >= GPU:
vittima = next((n for n, (k, _, _) in in_corso.items() if k == 1), None)
if vittima is None:
break
k, durata, _ = in_corso.pop(vittima)
heapq.heappush(coda, (1, 0, vittima, durata, 1)); rifatti += 1 # restarts from zero, with the full duration
while coda and len(in_corso) < GPU:
_, a, n, d, k = heapq.heappop(coda)
in_corso[n] = (k, d, t + d) # (class, duration, end minute)
t += 1
for n in [n for n, (k, d, f) in in_corso.items() if f <= t]:
fine[n] = t; del in_corso[n]
return fine, rifatti
arrivo = {n: a for a, d, k, n in LAVORI}
for nome, prel in (("FIFO", False), ("priority + preemption", True)):
fine, rif = simula(prel)
chat = [fine[n] - arrivo[n] for a, d, k, n in LAVORI if k == 0]
batch_fine = max(fine[n] for a, d, k, n in LAVORI if k == 1)
print(f"{nome:24s} mean interactive response {sum(chat) / len(chat):6.1f} min (max {max(chat)}) "
f"last batch finished at minute {batch_fine} jobs redone {rif}")
# Output:
# FIFO mean interactive response 81.2 min (max 115) last batch finished at minute 220 jobs redone 0
# priority + preemption mean interactive response 5.0 min (max 5) last batch finished at minute 265 jobs redone 4
With the simple queue the interactive jobs wait on average 81.2 minutes for a response, up to 115; with priority and preemption it takes 5 for all of them. The price is that four batch jobs are redone and the last one finishes at minute 265 instead of 220: 45 minutes of compute lost. This is the checkpoint theme again, which in a batch job with saves reduces the loss. The right policy depends on how much a minute of user waiting is worth compared with a minute of redone compute, and a single unit of measure, the hourly cost of the card, helps to compare them.
When none of this is needed
If you use a single card for a single service there is no consolidation, and if the load is so regular that it always stays under 50% the best planning is the simplest. If the jobs are few and short there is no checkpoint worth its cost. And if traffic is highly variable, first work out whether you really need a dedicated card: below a certain average utilization the comparison with APIs in the third article of the series gives a different result.
Frequently asked questions
What is the right utilization target for a GPU?
It depends on the wait the service tolerates and on how many servers share the queue. In the article's queueing model, with a single server the mean wait is 4 times the service time at 80% utilization; with four servers it is 0.75. Measure your own queueing wait and choose the threshold from there.
Time-slicing or MIG?
Time-slicing allows more workloads on the same card without isolating memory and faults; MIG partitions supported cards into isolated instances with dedicated resources. If one workload can make the others fail, you need isolation; if the workloads can tolerate each other, the density of time-slicing costs less.
Should you use spot instances for interactive inference?
Usually not, because a machine that can vanish at any moment has no checkpoint that saves the response in progress. For batch jobs, evaluations and indexing, with a well-chosen checkpoint, the cost can drop below on-demand: in the article's example to 0.47 with a checkpoint every half hour or every hour.
What you can do now
You know that the nvidia-smi utilization measures busy time and not capacity used, and which other measurements you need. You can explain why the utilization target depends on the tolerated wait and on the number of servers behind the queue. You can compare three consolidation rules by the overload time they produce, choose a checkpoint interval for interruptible instances, and evaluate a priority queue by the cost of the redone work. The parameters in the listings are invented: substitute your own. The next step is deciding how to balance cost, latency and quality, which is the subject of the article on the cost-quality trade-off.
Sources
- nvidia-smi (NVIDIA documentation) - definition of GPU utilization as the percentage of time with one or more kernels running; utilization query not supported on GPUs with MIG; accessed 2026-11-13
- Time-Slicing GPUs in Kubernetes (NVIDIA GPU Operator) - replicas of a GPU, no memory or fault isolation, comparison with MIG, DCGM-Exporter limit with time-slicing; accessed 2026-11-13
- NVIDIA Multi-Instance GPU User Guide - partitioning into isolated instances with dedicated compute and memory; accessed 2026-11-13
- Schedule GPUs (Kubernetes documentation) - GPUs are specified only in limits, request equal to limit; accessed 2026-11-13
- Spot VMs (Google Cloud documentation, cited as an example of a provider) - discounts of up to 91%, interruption possible at any time, suited to fault-tolerant workloads; accessed 2026-11-13
- Runs executed locally:
python3 -Ion the four listings (standard library), each twice with identical output; workloads, parameters and prices invented for the example. No GPU used. The Erlang C formula is a textbook model, not verified against an open source here

Commenti
Caricamento commenti...
Sign in to comment