When your own server pays off: the answer lies in utilization
A server with a GPU costs the same when it works and when it waits; an API is paid per token and costs nothing when nobody calls it. The whole choice between running a model yourself and paying for an API follows from this asymmetry: the cost per million tokens of a server is not a price, it is a fraction, that is, what you pay divided by how many tokens you really make it produce. This article builds the calculation step by step with four listings that were run, and shows why the traffic at two in the morning weighs as much as the price of the machine. A premise: real GPU and API prices change every few months and I do not quote them. All the figures in the listings are invented and declared as such in the code; replace them with your own quotes and measurements.
The article presupposes the map of the cost items and the techniques for reducing tokens: if you reduce tokens before deciding, the volume you reason on goes down, and with it the convenience of the server. For the sizing of GPUs in detail there is the article on GPU resource planning.
The cost per token of a server depends on how much you use it
Take a server rented at a fixed monthly price and a capacity, in tokens per second, that you measured on your model. At full load the cost per million tokens is the price divided by the monthly capacity. At any lower load, the unused capacity is paid for anyway: the cost per million rises in inverse proportion to utilization. The first listing computes it with an invented server at 1,200 euros a month and 800 tokens per second, and also derives the minimum utilization percentage above which the server beats an API at a given price.
# Cost per million tokens of your own server as a function of utilization. INVENTED figures.
SERVER_EUR_MONTH = 1200.0 # rent of a machine with a GPU, 24 hours a day
CAPACITY_TOK_S = 800 # sustained throughput: illustrative value, measure it on your model
SECONDS_MONTH = 30 * 24 * 3600
CAPACITY_MTOK = CAPACITY_TOK_S * SECONDS_MONTH / 1_000_000 # millions of tokens per month at full load
for utilization in (1.00, 0.60, 0.33, 0.10, 0.02):
eur_per_mtok = SERVER_EUR_MONTH / (CAPACITY_MTOK * utilization)
print(f"utilization {utilization:4.0%}: {CAPACITY_MTOK * utilization:8.1f} Mtok/month served, "
f"{eur_per_mtok:7.3f} EUR per million tokens")
for name, api_eur_mtok in (("Cheap API (0.60 EUR/Mtok)", 0.60), ("Premium API (6.00 EUR/Mtok)", 6.00)):
threshold = SERVER_EUR_MONTH / (api_eur_mtok * CAPACITY_MTOK)
print(f"{name}: the server breaks even only above {threshold:.1%} utilization")
# Output:
# utilization 100%: 2073.6 Mtok/month served, 0.579 EUR per million tokens
# utilization 60%: 1244.2 Mtok/month served, 0.965 EUR per million tokens
# utilization 33%: 684.3 Mtok/month served, 1.754 EUR per million tokens
# utilization 10%: 207.4 Mtok/month served, 5.787 EUR per million tokens
# utilization 2%: 41.5 Mtok/month served, 28.935 EUR per million tokens
# Cheap API (0.60 EUR/Mtok): the server breaks even only above 96.5% utilization
# Premium API (6.00 EUR/Mtok): the server breaks even only above 9.6% utilization
The line that governs the rest is SERVER_EUR_MONTH / (CAPACITY_MTOK * utilization). At 100% the server costs 0.58 euros per million tokens, at 33% it costs 1.75, at 10% it costs 5.79, at 2% a full 28.9 euros. The comparison with a cheap API at 0.60 euros per million is merciless: the server breaks even only if it works almost 96.5% of the time, so in practice it never pays off. With a premium API at 6 euros the threshold falls to 9.6%, and there even a lightly used server becomes convenient. The lesson is that the comparison is not «server against API» but «server against the price of the model you need»: if a small, cheap model via API is enough for your task, your own server starts at a disadvantage. The capacity of 800 tokens per second is an illustrative value: it depends on the model, on the number of parallel requests and on the length of the contexts, and must be measured with your own load.
The break-even volume, and when it does not exist
From the previous reasoning follows the classic formula: break-even happens at the volume V* = fixed cost / (API price − marginal cost of the server per million tokens). The fixed cost includes the rent and the maintenance hours of a person; the marginal cost of a rented server is close to zero. The formula holds under a condition that whoever applies it from memory forgets: V* must fall within the capacity of the server. If it exceeds it, the mathematical break-even exists but cannot be reached with a single machine. The second listing checks it for two invented scenarios and two API prices.
# Monthly volume above which your own server costs less than the API.
# Formula: V* = fixed_cost / (api_price - marginal_cost), valid only if V* fits within the capacity.
# INVENTED figures (EUR; volumes in millions of tokens per month; 500 tokens per request).
TOKENS_PER_REQUEST = 500
SCENARIOS = [ # name, server EUR/month, DevOps hours/month, marginal cost EUR/Mtok, capacity Mtok/month
("Small CPU, small model", 60.0, 1.0, 0.0, 4.0),
("One GPU, medium model", 1200.0, 8.0, 0.0, 2073.6),
]
DEVOPS_HOURLY_COST = 50.0
API_PRICES = (("cheap", 0.60), ("premium", 6.00))
def breakeven(fixed, marginal, api, capacity):
if api <= marginal:
return "never (the API costs less per token)"
v = fixed / (api - marginal)
if v > capacity:
return f"beyond capacity ({v:,.0f} > {capacity:,.0f} Mtok/month)"
requests_day = v * 1_000_000 / TOKENS_PER_REQUEST / 30
return f"{v:,.1f} Mtok/month = {requests_day:,.0f} requests per day"
for name, server, hours, marg, cap in SCENARIOS:
fixed = server + hours * DEVOPS_HOURLY_COST
for label, api in API_PRICES:
print(f"{name} (fixed {fixed:.0f}) vs {label} API: {breakeven(fixed, marg, api, cap)}")
# Output:
# Small CPU, small model (fixed 110) vs cheap API: beyond capacity (183 > 4 Mtok/month)
# Small CPU, small model (fixed 110) vs premium API: beyond capacity (18 > 4 Mtok/month)
# One GPU, medium model (fixed 1600) vs cheap API: beyond capacity (2,667 > 2,074 Mtok/month)
# One GPU, medium model (fixed 1600) vs premium API: 266.7 Mtok/month = 17,778 requests per day
The breakeven function returns three cases: «never», if the API costs less than the marginal cost; «beyond capacity», if V* exceeds what the server can produce; otherwise the volume, converted into requests per day at 500 tokens each. For the small CPU the break-even is never reachable: it would take 18 million tokens a month against the 4 the machine can produce. For the GPU, with the cheap API the break-even volume (about 2,667 million) exceeds the capacity (2,074); with the premium API the break-even is at about 267 million tokens a month, 17,778 requests a day. So, with these invented numbers, your own server makes sense only against a premium API and with traffic that keeps it constantly busy.
The fixed cost in the listing includes 8 hours a month of a person at 50 euros an hour: it is my estimate, and the most debatable item of the calculation. The time of whoever updates the model, checks quality after every change, answers when the service does not answer is always the most underestimated cost. There are other costs that the comparison usually forgets.
- The time to validate each new model on your task, because a more recent version is not automatically better on your data.
- Redundancy: a single server is a single point of failure, two double the fixed cost.
- Queues: a server has a limit of parallel requests, and beyond that limit requests wait or are rejected.
- The opportunity cost of whoever manages the infrastructure instead of building product features.
Each of these costs grows with the seriousness of the service, not with the volume of tokens: a service that must stay up at night and on weekends requires on-call duty and redundancy even if it moves few requests. That is why the break-even computed with the rent alone is an optimistic bound, and the real number is higher. On queues, Ollama's documentation says that for each model the parallel requests are one by default, that the required memory grows with the product of parallelism and context length, and that beyond the maximum queue (512 by default) the server answers with a 503 error. The capacity in tokens per second is therefore not enough: it also matters how many requests together the server sustains without making users wait.
The traffic at two in the morning: you size on the peak hour
So far I have treated the load as uniform, and it is the assumption that goes wrong most often. A server is bought to sustain the busiest hour, not the average: if in a peak hour more tokens arrive than a machine produces, users wait. The cost is then computed on the number of servers needed at the peak, and the traffic of the other hours decides how much those servers work. The third listing compares three daily shapes with the same total volume (40 million tokens a day): daytime, flat and night-time from batch jobs.
# The server is sized on the peak hour, not on the average. INVENTED figures.
import math
SHAPES = { # share of traffic for each hour of the day (sum 1)
"daytime (B2B)": [2,1,1,1,2,5,15,45,80,95,100,95,85,90,95,85,80,70,45,30,25,18,12,8],
"flat": [1] * 24,
"night (batch)": [40,60,90,95,80,60,40,30,25,20,15,15,15,15,15,15,15,20,25,30,35,40,45,45],
}
TOKENS_DAY = 40_000_000
CAPACITY_HOUR = 800 * 3600 # tokens per hour of one server
SERVER_EUR_MONTH = 1200.0
API = {"cheap": 0.60, "premium": 6.00} # EUR per million tokens
MTOK_MONTH = TOKENS_DAY * 30 / 1_000_000
for name, weights in SHAPES.items():
tot = sum(weights)
peak_hour = TOKENS_DAY * max(weights) / tot
servers = math.ceil(peak_hour / CAPACITY_HOUR)
utilization = (TOKENS_DAY / 24) / (servers * CAPACITY_HOUR)
cost = servers * SERVER_EUR_MONTH
night = sum(weights[:6]) / tot
print(f"{name:14s} peak/avg {max(weights) * 24 / tot:4.1f} share 0-6 {night:5.1%} "
f"servers {servers} avg utilization {utilization:5.1%} {cost / MTOK_MONTH:5.2f} EUR/Mtok")
print(f"Cheap API {API['cheap']:.2f} EUR/Mtok, premium API {API['premium']:.2f} EUR/Mtok")
# Output:
# daytime (B2B) peak/avg 2.2 share 0-6 1.1% servers 2 avg utilization 28.9% 2.00 EUR/Mtok
# flat peak/avg 1.0 share 0-6 25.0% servers 1 avg utilization 57.9% 1.00 EUR/Mtok
# night (batch) peak/avg 2.6 share 0-6 48.0% servers 2 avg utilization 28.9% 2.00 EUR/Mtok
# Cheap API 0.60 EUR/Mtok, premium API 6.00 EUR/Mtok
The three rows have the same volume and different costs. Daytime traffic has a peak hour 2.2 times the average and only 1.1% of the traffic between midnight and six: two servers are needed, working on average 28.9%, and the cost rises to 2.00 euros per million tokens. Flat traffic requires one server, used at 57.9%, at 1.00 euro. Night-time batch traffic has a peak-to-average ratio of 2.6 and costs the same as the daytime one. Against a cheap API at 0.60 euros, none of the three shapes pays off; against a premium API at 6 euros, all three do, but the flat shape pays off six times over and the daytime one three. The remedy, for jobs that have no user waiting (summaries, classifications, indexing), is to move them into the empty hours: flattening the curve is worth as much as one server less. For user traffic there is no remedy, and the empty night remains a cost.
The hybrid architecture: a server for the base load, the API for the rest
If the cost is decided by the peak, it makes sense to size the server on the base traffic and send to the API the part that exceeds it. The fourth listing computes, hour by hour, how many tokens the server serves and how many go to the API, and looks for the number of servers that minimizes the monthly cost, for two API prices. The profile is the daytime one of the previous listing.
# Own server for the base load, API for the rest: how many servers should you keep? INVENTED figures.
WEIGHTS = [2,1,1,1,2,5,15,45,80,95,100,95,85,90,95,85,80,70,45,30,25,18,12,8] # daytime profile
TOKENS_DAY = 40_000_000
CAPACITY_HOUR = 800 * 3600
SERVER_EUR_MONTH = 1200.0
HOURLY = [TOKENS_DAY * w / sum(WEIGHTS) for w in WEIGHTS]
def monthly_cost(n_servers, api_eur_mtok):
on_server = [min(t, n_servers * CAPACITY_HOUR) for t in HOURLY]
on_api = sum(t - s for t, s in zip(HOURLY, on_server))
api = on_api * 30 / 1_000_000 * api_eur_mtok
api_share = on_api / TOKENS_DAY
return n_servers * SERVER_EUR_MONTH + api, api_share
for name, price in (("Cheap API 0.60", 0.60), ("Premium API 6.00", 6.00)):
print(name)
rows = [(n, *monthly_cost(n, price)) for n in range(0, 4)]
best = min(rows, key=lambda r: r[1])[0]
for n, cost, api_share in rows:
mark = " <- minimum" if n == best else ""
print(f" {n} servers: {cost:8.0f} EUR/month, {api_share:5.1%} of tokens on API{mark}")
# Output:
# Cheap API 0.60
# 0 servers: 720 EUR/month, 100.0% of tokens on API <- minimum
# 1 servers: 1268 EUR/month, 9.4% of tokens on API
# 2 servers: 2400 EUR/month, 0.0% of tokens on API
# 3 servers: 3600 EUR/month, 0.0% of tokens on API
# Premium API 6.00
# 0 servers: 7200 EUR/month, 100.0% of tokens on API
# 1 servers: 1876 EUR/month, 9.4% of tokens on API <- minimum
# 2 servers: 2400 EUR/month, 0.0% of tokens on API
# 3 servers: 3600 EUR/month, 0.0% of tokens on API
With the cheap API the minimum is zero servers: 720 euros a month with the API only, against 1,268 with one server and 2,400 with two. With the premium API the minimum is one server: 1,876 euros a month, with 9.4% of the tokens overflowing to the API, against 7,200 all-API and 2,400 with two servers. The second server does not pay off because it works only in the peak hours. The operational conclusion is that the optimum often sits in the middle, but it depends on the ratio between the price of the server and that of the API: this is why it is worth writing the calculation with your own numbers instead of trusting a rule.
The hybrid has two costs that the listing does not see. The first is quality: two different models answer differently, and a user who receives answers of different style or accuracy depending on the hour notices; the quality test must be done on both. The second is confidentiality: if the reason you keep a model in-house is that the data must not leave, the overflow to the API sends exactly that data out in the peak hours. In that case the hybrid must be excluded or limited to requests without sensitive data.
What decides beyond the money
Often the choice is not economic, and that should be declared. The table collects the non-monetary factors and the question to ask the team for each; I gave no scores, because a score from 1 to 5 per factor turns a judgment into a figure with the appearance of a measurement.
| Factor | Leans toward your own server if... | Leans toward the API if... | Question for the team |
|---|---|---|---|
| Data privacy | The data must not leave your perimeter | The provider's terms are acceptable for that data | What does the contract say about processing and retention? |
| Skills | Someone knows how to run, update and measure an inference service | The team is small and must deliver product features | Who answers when the service stops on a Saturday? |
| Required quality | A model you can run is enough for the task | You need a model you can only get via API | Do you have a test set with known answers to compare them? |
| Traffic shape | The load is constant or can be moved | The load comes in peaks with long gaps | What is the ratio between the peak hour and the average? |
| Time to market | The infrastructure already exists | You must start within a few weeks | How much delay do you accept in order to save? |
The factor that is most often decisive is confidentiality, and when it is, the economic comparison takes second place: if the data cannot leave, your own server is a requirement and the calculation serves only to size it. An honest way of presenting it to whoever decides is to say which row of the table weighed more than the figures. Even whoever chooses their own server for reasons of learning or control, at low volume, must know they are paying for that advantage, and how much: with the first listing the bill is a multiplication.
Frequently asked questions
From how many tokens a day does your own server pay off?
There is no universal threshold: it depends on the price of the model via API that you replace, on the fixed cost of the server and on the shape of the traffic. In the article's example, with invented numbers, break-even against a cheap API is not reachable and against a premium one it sits around 267 million tokens a month.
Why does night traffic change the calculation?
Because the server is sized on the peak hour and costs even when it is idle. With the same total volume, daytime traffic requires two servers used at 29%, flat traffic one server used at 58%: the cost per million tokens doubles. Jobs with no user waiting can be moved into the empty hours.
Does the hybrid architecture always pay off?
No. With a cheap API the minimum of the listing is zero servers; with a premium one it is a single server with 9.4% of the tokens in overflow. It depends on the ratio between the price of the server and the price of the API, and it adds two costs: the different quality between the two models and the exit of data in the peak hours.
What you can do now
You can compute the cost per million tokens of a server as the price divided by the tokens actually served, and derive the utilization percentage above which it beats the API you want to replace. You can apply the break-even formula checking that the volume fits within the capacity, and size on the peak hour and not on the average. You can evaluate a hybrid architecture by looking for the number of servers that minimizes the cost and remembering that two different models and the exit of data are costs the calculation does not see. All the figures are examples: replace them with your own quotes and your own traffic curve. To forecast how the spend grows in the coming months, move on to article 4.
Sources
- Ollama FAQ - default per-model parallelism of 1, memory proportional to parallelism times context length, maximum queue of 512 requests and a 503 response beyond the limit; consulted on 2026-11-12
- Efficient Memory Management for Large Language Model Serving with PagedAttention (arXiv:2309.06180, SOSP 2023) - throughput depends on the number of batched requests; vLLM improves throughput by 2-4 times at the same latency compared with the systems of the time, according to the authors; abstract read on 2026-11-12
- Pricing (Anthropic) - example of per-token billing with separate prices for input and output; consulted on 2026-11-12
- Tests run locally:
python3 -Ion the four listings (standard library), each one twice with identical output; prices, capacities and traffic curves invented for the example

Commenti
Caricamento commenti...
Sign in to comment