DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Serverless or Always-On GPUs? The Break-Even Math for LLM Inference
Content sponsored by Runpod logo

Serverless or Always-On GPUs? The Break-Even Math for LLM Inference

Scaling serverless GPUs to zero reduces idle costs, but long cold-start times can degrade the user experience and add to overall latency.

By 
Matt Sarrel
·
Dec. 04, 26 · Analysis
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
13 Views

Deciding whether to use serverless scale-to-zero or always-on GPUs for LLM inference forces engineers to balance idle cost savings against crippling cold-start delays. Here's a framework to help you make the best decision about your AI infrastructure. 

I started with a small LLM inference workload: one GPU worker handling 864 requests a day, with each request taking 2 seconds. In the simulation, scaling to zero cost $36.00 a day, against $56.88 to keep the worker running. That looks like an easy saving until you look at the waits. With a 5-second idle timeout and a 91-second startup, 95.1% of arrivals waited for the worker to become ready. I wouldn’t choose that setting for an interactive endpoint.

Reducing those waits eats into the saving. To hold startup waits to 5% of arrivals, the estimated idle timeout rises to 369 seconds, and the worker is billed for 97.7% of the day. At that point, the always-on discount wins. These are simulated results, not a production benchmark, and a startup-wait allowance does not establish a p95 result. I use Runpod for a few platform examples, but the method applies to any AI infrastructure provider with comparable billing.

One Worker, 864 Requests a Day

The comparison uses a scale-to-zero rate equivalent to $3 per hour and a 21% always-on discount: 24 × $3 × 0.79 = $56.88 per day. Service time is 2 seconds and startup time is fixed at 91 seconds. The discount comes from the post linked below; check your own quote. The prices and startup inputs are illustrative, and the simulation counts only billed time within the 24-hour window.

Requests per day

Idle timeout

Billed share of day

Startup-wait share

Scale-to-zero cost per day

Always-on cost per day

864

5 s

50.0%

95.1%

$36.00

$56.88

864

100 s

73.2%

52.0%

$52.67

$56.88

864

600 s

99.7%

0.7%

$71.79

$56.88

2,000

5 s

70.8%

91.8%

$50.96

$56.88

2,000

120 s

94.9%

16.3%

$68.33

$56.88

2,000

300 s

99.9%

0.4%

$71.89

$56.88


Daily cost at 864 requests per day, using the inputs above

Figure 1. Daily cost at 864 requests per day, using the inputs above. Scale-to-zero crosses the $56.88 always-on cost at about a 130-second idle timeout. Startup-wait share falls from 95% at 5 seconds to 52% at 100 seconds: the lower bill comes with more requests waiting for startup.


Those waits don’t all last 91 seconds. The triggering request waits the full startup; later arrivals wait the remaining time, plus any queueing. Increasing the idle timeout to 100 seconds reduces startup-wait share to 52.0% and costs $52.67. By 600 seconds, the bill reaches $71.79, about 26% above always-on. That is more money to keep a worker warm without getting the always-on rate.

Allowing half the arrivals to wait for startup still leaves a small saving for the 864-request workload: an estimated 106-second timeout costs about $53.52. Tightening that allowance to 40% takes 132 seconds and costs about $56.94, just above always-on. More traffic makes the tradeoff worse. At 2,000 requests per day, a 120-second timeout costs $68.33, about 20% more than always-on, while 16.3% of arrivals still wait for startup.

Why Billed Time Matters

The model bills the full startup delay, request execution and idle timeout. Its startup input represents both billed duration and time until readiness. If readiness includes unbilled provisioning or capacity waits, model those separately. Check your provider’s image-pull charges and minimum billing increments too. Always-on capacity is billed throughout the provisioned period, including time with no requests.

The crossover depends on how much of the day is billed. For one worker under steady Poisson traffic, the share of requests that trigger startup gives another way to compare the costs:

  • Scale-to-zero cost = 24 × p × b = 24 × p × (1 − c)
  • Always-on cost = 24 × p × (1 − d)
  • Break-even: b = 1 − d (equivalently c = d in the long run for steady Poisson traffic)

Here p is the scale-to-zero rate expressed per hour, b is the billed fraction of the day, c is the share of requests that trigger a startup, and d is the always-on discount. Use fractions: 5% is 0.05. The exact cost test is b < 1 − d. For steady Poisson arrivals over a long period, b = 1 − c, so the equivalent test is c > d; a finite-day simulation only approximates that identity.

Let w be the share of requests that wait for startup: both the triggering request and requests arriving before the worker is ready. The startup-wait allowance ε limits w, not c. A cheaper configuration within that allowance must satisfy b < 1 − d and w ≤ ε. For positive startup duration, w ≥ c, so ε > d remains a necessary long-run screening condition, but it is not sufficient. Use the script to check both conditions for each traffic period.

How the Startup Count Connects to Cost

With steady Poisson traffic, requests arrive independently of whether the worker is running. Over time, the fraction that reaches it when stopped matches the fraction of time it is stopped. That connects the startup count to billed time.

I checked that relationship in 24 simulation cases: service times of 0.5 and 2 seconds, startups of 5 and 91 seconds, idle timeouts of 5 and 60 seconds, and 300, 864 and 2,000 requests per day. Billed share and one minus the trigger share differed by less than 1.5 percentage points. That supports the finite-day approximation, but leaves the question of production latency unanswered.

Keeping the worker around longer avoids some starts, but that extra idle time is billed at the full scale-to-zero rate.

What a Tighter Wait Allowance Costs

For a p95 target, at most 5% of requests can miss the deadline; for p99, it is 1%. Queueing and slow execution need room in that allowance too. Some requests wait briefly for startup and still meet the deadline; others arrive after startup and get stuck behind the backlog. The script counts startup waits rather than deadline misses, so use measured end-to-end latency to check p95 or p99.

The table uses a 2-second service time, fixed 91-second startup and startup-wait allowances of 5% or 1%. Each of the 12 simulation seeds starts the day with the worker off. Validate the estimated timeouts on other seeds and real traffic to reproduce this work on your own AI infrastructure.

Requests per day

Startup-wait allowance

Estimated idle timeout

Billed share of day

864

5%

369 s

97.7%

864

1%

544 s

99.6%

2,000

5%

175 s

98.5%

2,000

1%

251 s

99.7%


At these allowances, the worker is billed for roughly 98% to 100% of the day. Always-on at 79% of the undiscounted rate costs less in all four cases.

It's also important to understand how your infrastructure provider bills. This comparison covers usage rates; a commitment in a contract could mean paying for capacity after it is no longer needed.

A Longer Startup Leaves Less Room to Save

Changing only startup duration shows how much it affects the bill. Traffic stays at 864 requests per day, service time stays at 2 seconds, and prices stay fixed. The 45-second case is illustrative. The 91- and 324-second inputs come from the published end-to-end delays; neither is a measured mean billed startup time for this workload. 

startup time idle timeout startup-wait share scale-to-zero cost per day always-on cost per day

45 s

5 s

94.8%

$24.87

$56.88

45 s

100 s

45.8%

$49.84

$56.88

91 s

5 s

95.1%

$36.00

$56.88

91 s

100 s

52.0%

$52.67

$56.88

324 s

5 s

97.0%

$55.74

$56.88

324 s

100 s

70.8%

$60.42

$56.88


With a 324-second startup and a 5-second timeout, scale-to-zero costs $55.74 versus $56.88 for always-on, but 97.0% of arrivals wait for startup. A 100-second timeout costs $60.42 and still leaves 70.8% waiting. Longer startups add billed time and make more arrivals wait for the same initialization.

In the simulation, s is elapsed service time per request on a sequential worker, and C is billed startup duration. Both stay constant; the model does not cover batching or a distribution of startup times. Caching the model or retaining worker state can shorten C. Runpod’s FlashBoot, for example, retains state for faster restarts, but reusing a snapshot depends on returning to the same host and image. Bursty, low-volume endpoints may benefit less. Remeasure startup after changing those settings, or similar settings for another provider, then compare costs again.

Use the mean for C because the bill includes slow starts too. In a previous blog post, Runpod reported four Qwen3-8B baseline runs on a single 48 GB GPU: 273, 355, 387 and 834 seconds. Their median is 371 seconds; their mean is about 462. Four runs are too few for a benchmark, but they show why the choice matters. The 32B tests report baseline delays of 331, 309 and 324 seconds (mean 321.3; median 324), and optimized delays of 93 and 89 seconds (mean and median 91). These are submission-to-pickup delays, which can include unbilled provisioning or capacity waits. The examples use 91 and 324 seconds as fixed sensitivity inputs, not verified mean billed startup times. Measure your own billed startup duration.

LLM Inference Cost Per Million Tokens

Assuming 864 completed requests a day at 300 output tokens each, daily output is 0.2592 million tokens. Dividing daily cost by that output gives $219.44 per million output tokens for always-on and $203.21 for scale-to-zero with a 100-second timeout. A different average output length would change those figures. Here, request execution takes only 2% of the day; startup and idle time account for the rest of the bill.

Why the Per-Request Calculation Fails

Per-request estimates incorrectly include a full startup and idle window in every request. In reality, arriving requests share open idle windows, extending shutdown deadlines only by their service time and arrival gap. Under a 5-second timeout, this flaw miscalculates the break-even volume at ~700 requests daily instead of the actual ~3,070 steady-state calculation. Across 5–120s timeouts and 21–40% discounts, per-request math underestimates break-even thresholds by 2.0x to 4.4x.

The table gives steady-state Poisson break-even volumes for a sequential worker with s = 2 seconds and C = 91 seconds. For this model, c = (1 − λs) / (exp(λτ) + λC), where λ is requests per second, τ is idle timeout in seconds, and λs < 1. Solve c = d and round to the nearest 10 requests per day. The script’s break_even_volume function reproduces these values.

Idle timeout

d = 21%

d = 30%

d = 40%

5 s

3,070

1,960

1,280

30 s

2,230

1,470

980

120 s

940

680

480


Changing request duration moved the break-even less than changing startup time or idle timeout in these examples. At a 60-second timeout and a 21% discount, the rounded steady-state break-even is 1,560 requests per day at 2 seconds per request, 1,410 at 8 seconds and 1,260 at 15 seconds.

A Different Answer Overnight

I also tried a workload with 1,500 daily requests: 1,275 during nine business hours and 225 during the other 15 hours. Service takes 15 seconds, startup takes 91 seconds, and idle timeout is 60 seconds. Across the day, billed share is 63.6%, while 89.2% of requests do not trigger startup. One averages weights time; the other weights requests. Within each period, the shares are closer: 97.1% billed versus 97.0% non-triggering during business hours, and 44.2% versus 42.5% overnight. Finite samples and period boundaries explain the remaining gaps. Even so, 78.3% of overnight arrivals wait for startup.

Splitting the bill by period changes the answer. During business hours, scale-to-zero bills about 97% of the time, so always-on at 79% of the rate is cheaper. The sparse overnight traffic leaves more room to save.

Configuration

Startup-wait share

Cost per day

Always-on all day

0.0%

$56.88

Scale to zero all day, 5 s timeout

47.4%

$39.68

Scale to zero all day, 60 s timeout

22.8%

$45.79

Scale to zero all day, 300 s timeout

5.3%

$61.31

Always-on by day, scale to zero overnight, 5 s timeout

13.9%

$36.33

Always-on by day, scale to zero overnight, 60 s timeout

11.7%

$41.24

Always-on by day, scale to zero overnight, 300 s timeout

4.9%

$55.79

Always-on by day, scale to zero overnight, 108 s timeout

10.0%

$44.93


None of the listed scale-to-zero configurations meets a 4% startup-wait allowance. A hybrid tuned to 4% needs an estimated 354-second overnight timeout and costs $57.80, above $56.88 for always-on. For a 10% allowance, the estimated overnight timeout is 108 seconds and hybrid cost is $44.93, about 21% below always-on. The all-day 60-second option costs $45.79 and misses that allowance at 22.8%.

The hybrid estimates use each period’s traffic converted to a daily rate: (requests in the period ÷ hours in the period) × 24. The periods are priced separately, assuming a worker is ready at the start of business hours. That leaves out prewarming, handoff and transition costs. simulate_day covers continuous all-day scale-to-zero; validating the scheduled hybrid takes a separate simulation or logs.

If your platform exposes an API for endpoint settings, raise the minimum early enough for workers to become ready before business hours. Include any billed prewarming and transition time when comparing the real schedule with the period estimates.

Optimizing the Endpoint

The comparison points to five endpoint settings. Their names and controls vary by provider:

  • Set the minimum worker count to zero only when the tested configuration meets the startup-wait allowance and costs less than always-on. The ε > d screen alone cannot establish either result. Otherwise, size a ready worker floor from measured demand and latency, with additional workers for overflow. In the daily example, the proposed floor is one during business hours and zero overnight.
  • Size the maximum from measured peak in-flight demand and tested worker concurrency, then add spare capacity. Arrival rate × end-to-end latency estimates mean demand in a stable system, not the peak. Here, 1,275 requests over nine hours × 15 seconds gives 0.59 workers of sequential processing load; an assumed threefold burst gives 1.77. Neither figure includes startup or queueing delay. Eight concurrent requests per worker and a maximum of two workers are load-test inputs, not simulation results. Enable concurrency in both the handler and serving engine; simply launching more GPU jobs can exhaust memory.
  • Use the script (below) to estimate an idle timeout that meets the period’s startup-wait allowance. Confirm when your provider stops billing: a worker waiting for another request may still incur charges, regardless of its console status. Test the timeout against your latency target. For reference, Runpod's console default is 5 seconds, and its REST v2 default is 10 seconds.
  • Where available, compare scaling based on queue delay with scaling based on outstanding requests. A queue-delay policy waits for a threshold before adding capacity, so include that delay in your latency budget. For request-based scaling, check which requests the provider counts and how it converts that count into workers. For example, a policy that divides pending plus in-progress requests by a jobs-per-worker target should use a target consistent with tested concurrency: eight in this example. Validate the policy under bursts and during cold starts.
  • Keep GPUs per worker at 1 unless the model does not fit on a single GPU. Adding GPUs can raise the per-second rate of every worker, including the always-on ones.

Where the Calculation Stops

The cost comparison does not establish whether the endpoint meets its SLA. The model queues overlapping arrivals on one sequential worker and reports no queueing-time or end-to-end latency percentile. Later arrivals delayed by the backlog do not count toward startup-wait share. That matters at about 59% offered processing load during business hours. Checking the SLA takes measured latency distributions. Batching, parallel service or fleet autoscaling need a model of the actual serving behavior.

In the logs, compare billed-time share with one minus startup-trigger share c. Using startup-wait share w there would give the wrong comparison. A gap can come from finite samples, period boundaries, traffic that isn’t Poisson, or the provider’s billing rules.

Check your provider’s inactivity policy for low-volume endpoints. Scaling workers to zero and disabling an unused endpoint are different behaviors. If inactivity can reduce worker limits or suspend the endpoint, monitor its ability to serve requests and document how to restore it.

A week of real logs and an actual always-on quote are the starting point. Use them to estimate a timeout for each traffic period, then test nearby settings against the bill and measured latency.

The Script

The script reruns the comparison with different traffic and startup assumptions. It needs a request count, sequential service time and startup time in seconds, plus the startup-wait allowance and discount as fractions. simulate and simulate_day spread a fixed request count uniformly across a day or its traffic periods, with the worker off at the start and billing clipped at midnight. They return billed share, startup-trigger share c and startup-wait share w. decide estimates an integer timeout and compares capacity costs with running all day at the undiscounted rate. For the long-run Poisson comparison, use steady_state and break_even_volume.

Python
 
import math
import random

DAY = 86400.0

def _count(value, name):
    if isinstance(value, bool) or not isinstance(value, int) or value < 0:
        raise ValueError(f"{name} must be a nonnegative integer")

def _check(service, cold_start, idle_timeout, seeds):
    if any(not math.isfinite(x) or x < 0 for x in (service, cold_start, idle_timeout)):
        raise ValueError("Times must be finite and nonnegative")
    _count(seeds, "seeds")
    if seeds == 0:
        raise ValueError("seeds must be positive")

def _trace(arrivals, service, cold_start, idle_timeout, horizon=DAY):
    """Billed seconds, startup triggers and arrivals that wait for startup."""
    billed = triggers = waiting = 0
    start = None
    ready_at = free_at = 0.0
    for t in arrivals:
        if start is None or t > free_at + idle_timeout:
            if start is not None:
                billed += max(0.0, min(free_at + idle_timeout, horizon) - start)
            start, ready_at = t, t + cold_start
            free_at = ready_at
            triggers += 1
        waiting += t < ready_at
        free_at = max(t, free_at) + service
    if start is not None:
        billed += max(0.0, min(free_at + idle_timeout, horizon) - start)
    return billed, triggers, waiting

def simulate(requests_per_day, service, cold_start, idle_timeout, seeds=12):
    """Fixed daily count, uniformly timed arrivals; worker starts off.
    Returns (billed-day fraction, trigger share, startup-wait share).
    Queueing is simulated, but no latency percentile is calculated.
    """
    _count(requests_per_day, "requests_per_day")
    _check(service, cold_start, idle_timeout, seeds)
    if requests_per_day == 0:
        return 0.0, 0.0, 0.0
    if requests_per_day * service >= DAY:
        raise ValueError("One worker cannot sustain this average load")
    totals = [0.0, 0.0, 0.0]
    for seed in range(seeds):
        rng = random.Random(seed)
        arrivals = sorted(rng.uniform(0, DAY) for _ in range(requests_per_day))
        b, c, w = _trace(arrivals, service, cold_start, idle_timeout)
        for j, value in enumerate((b / DAY, c / requests_per_day, w / requests_per_day)):
            totals[j] += value / seeds
    return tuple(totals)

def find_idle_timeout(requests_per_day, service, cold_start, tolerance):
    """Estimated minimum integer timeout for the simulated startup-wait budget.
    Binary search assumes a decreasing response in expectation. Recheck
    on other seeds or production traces before using the result.
    """
    if not math.isfinite(tolerance) or not 0 <= tolerance <= 1:
        raise ValueError("tolerance must be a fraction from 0 to 1")
    low, high = -1, int(DAY)
    if simulate(requests_per_day, service, cold_start, high)[2] > tolerance:
        raise ValueError("Budget is infeasible with a worker that starts off")
    while high - low > 1:
        mid = (low + high) // 2
        if simulate(requests_per_day, service, cold_start, mid)[2] <= tolerance:
            high = mid
        else:
            low = mid
    return high

def decide(requests_per_day, service, cold_start, tolerance, discount):
    if not math.isfinite(discount) or not 0 <= discount <= 1:
        raise ValueError("discount must be a fraction from 0 to 1")
    idle = find_idle_timeout(requests_per_day, service, cold_start, tolerance)
    billed, triggers, waiting = simulate(requests_per_day, service, cold_start, idle)
    always_on_cost = 1 - discount  # Relative cost, not billed-time share.
    choice = "scale to zero" if billed < always_on_cost else "always on"
    return choice, idle, triggers, waiting, billed, always_on_cost

def steady_state(requests_per_day, service, cold_start, idle_timeout):
    """Long-run Poisson arrivals, one sequential worker, constant startup time."""
    _check(service, cold_start, idle_timeout, 1)
    rate = requests_per_day / DAY
    if rate < 0 or not math.isfinite(rate) or rate * service >= 1:
        raise ValueError("Arrival rate must be finite and the queue stable")
    exponent = rate * idle_timeout
    c = 0.0 if exponent > 700 else (1 - rate * service) / (math.exp(exponent) + rate * cold_start)
    return 1 - c, c, 0.0 if cold_start == 0 else (1 + rate * cold_start) * c

def break_even_volume(service, cold_start, idle_timeout, discount):
    """Long-run requests/day where the billed fraction equals 1 - discount."""
    _check(service, cold_start, idle_timeout, 1)
    if service <= 0 or not 0 < discount < 1:
        raise ValueError("Use positive service time and a discount between 0 and 1")
    low, high = 0.0, DAY / service * (1 - 1e-12)
    for _ in range(60):
        mid = (low + high) / 2
        if steady_state(mid, service, cold_start, idle_timeout)[1] > discount:
            low = mid
        else:
            high = mid
    return high

def simulate_day(periods, service, cold_start, idle_timeout, seeds=12):
    """Continuous full-day simulation. periods: (start hour, end hour, count).
    Returns (billed-day fraction, trigger share, startup-wait share).
    """
    _check(service, cold_start, idle_timeout, seeds)
    last = 0
    for a, b, n in sorted(periods):
        _count(n, "period requests")
        if not (last <= a < b <= 24):
            raise ValueError("Periods must be nonoverlapping and within one day")
        if n * service >= (b - a) * 3600:
            raise ValueError("One worker cannot sustain this period's average load")
        last = b
    total = sum(n for _, _, n in periods)
    if not total:
        return 0.0, 0.0, 0.0
    totals = [0.0, 0.0, 0.0]
    for seed in range(seeds):
        rng = random.Random(seed)
        arrivals = sorted(rng.uniform(a * 3600, b * 3600)
                          for a, b, n in periods for _ in range(n))
        b, c, w = _trace(arrivals, service, cold_start, idle_timeout)
        for j, value in enumerate((b / DAY, c / total, w / total)):
            totals[j] += value / seeds
    return tuple(totals)

if __name__ == "__main__":
    for n, allowance in ((864, 0.50), (864, 0.40), (864, 0.20), (2000, 0.05)):
        choice, idle, c, w, billed, always = decide(n, 2.0, 91.0, allowance, 0.21)
        print(f"{n}/day, budget {allowance:.0%}: {choice}; timeout {idle}s; "
              f"triggers {c:.1%}; startup waits {w:.1%}; "
              f"relative costs {billed:.1%} vs {always:.1%}")

    business, overnight = 3400, 360  # Daily-equivalent request rates.
    night_budget = 0.10 * 1500 / 225
    choice, idle, c, w, billed, _ = decide(overnight, 15.0, 91.0, night_budget, 0.21)
    hybrid = 9 * 0.79 + 15 * billed
    print(f"Overnight: {choice}; timeout {idle}s; startup waits {w:.1%}")
    print(f"Hybrid estimate: ${3 * hybrid:.2f} vs ${3 * 24 * 0.79:.2f}/day")
    # Hybrid estimates price each period separately; no transition or prewarming costs.
    day = [(9, 18, 1275), (0, 9, 135), (18, 24, 90)]
    for timeout in (5, 60, 300):
        b, c, w = simulate_day(day, 15.0, 91.0, timeout)
        nb, nc, nw = simulate(overnight, 15.0, 91.0, timeout)
        print(f"{timeout}s: all-day cost ${72*b:.2f}, waits {w:.1%}; "
              f"hybrid estimate ${3*(9*0.79+15*nb):.2f}, waits {nw*225/1500:.1%}")
    for timeout in (5, 30, 120):
        values = [round(break_even_volume(2, 91, timeout, d) / 10) * 10
                  for d in (0.21, 0.30, 0.40)]
        print(f"{timeout}s steady-state break-even requests/day: {values}")


For the 864-request endpoint, I’d keep the worker running if users need the fastest responses. The 37% saving at a 5-second timeout comes with startup waits for 95.1% of arrivals. Limiting those waits to 5% leaves the worker billed for 97.7% of the day, so the always-on discount wins. Scale-to-zero makes more sense for work that can wait, or for quiet hours where the full schedule still saves money after prewarming and transitions.

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook