Concepts / Cost Per Request for Inference Services

Cost Per Request for Inference Services

Throughput measures the output tokens per second an inference service generates across all users, and it can also be expressed as completed requests per second or per minute.

  • Programming

Two Services on the Same Hardware

Imagine two inference services running on identical hardware. The first finishes a large number of requests every minute, and the second finishes fewer. If you look only at that first number, the first service seems better. Yet the users of the first service may wait far too long for their answers to begin, while the second service keeps its responses prompt. Counting finished work alone cannot separate these two situations. This article introduces two measurements that do: throughput, which counts how much work a service completes, and goodput, which counts only the work that meets a set of performance targets. Throughput also connects directly to cost, so the same measurements tell you what each served request actually costs.

What do you think happens?

Two services run on identical hardware. The first completes more requests every minute than the second. Which service is better for its users?

Reveal answer
Answer:

The count alone does not settle it. The first service may make users wait too long before their answers begin, so the second service, with fewer completions but prompt responses, may deliver the better experience.

Throughput measures how much work is finished, not how the experience feels to each user. The rest of this article shows how a second measure, goodput, captures the difference.

What Throughput Measures

Definition

Throughput describes how many output tokens per second an inference service can generate, summed across every user and every request it is handling at the moment. It is a property of the whole service rather than of a single conversation. When someone says throughput without any qualifier, they almost always mean output tokens.

Throughput can also be reported in requests rather than tokens. A service that completes requests can be described by how many requests it finishes per second or per minute. The two units describe the same service from different angles. A token count tells you how much text the service produces, while a request count tells you how many separate jobs it finishes. The table below lays out both units.

UnitWhat it countsExample reading
Output tokens per secondTokens generated across all users each second100 tokens per second
Output tokens per minuteThe same output, scaled to one minute6,000 tokens per minute
Requests per secondCompleted requests each second10 requests per second
Requests per minuteCompleted requests each minute100 requests per minute

Throughput expressed in token units and request units. The token rate and the request rate describe the same service, but they measure different things.

Adding Up Output Across Concurrent Users

The service-level number is a sum. Each active request contributes the output tokens it is generating right now, and the service reports the total. The following worked example follows that addition step by step, using a small generated scenario with three users.

Worked example

Summing tokens per second across three users

Three users are being served at the same moment. User A's request generates 30 output tokens per second, user B's request generates 25 output tokens per second, and user C's request generates 45 output tokens per second. What is the service's throughput in output tokens per second?

  1. 1
    Identify what each active request contributes

    Each request contributes its own output rate: 30 for user A, 25 for user B, and 45 for user C.

  2. 2
    Add the contributions

    Summing across all users gives 30 + 25 + 45 = 100 tokens per second.

  3. 3
    Name the unit correctly

    The total is a service-level throughput of 100 output tokens per second, because it sums every user the service is handling at that moment.

Result

The service's throughput is 100 output tokens per second. No single user saw 100 tokens per second; the figure belongs to the whole service.

From Hardware Price to Cost Per Token

Throughput is directly tied to compute cost. A higher throughput generally means a lower cost per unit of output, because the same hourly hardware price is spread across more generated tokens. The source works through the arithmetic with specific numbers. Follow the same chain of reasoning step by step, because the same method applies to any hardware price and any throughput figure.

Rule

In this formula, P is the hardware price per hour and T is the throughput in output tokens per second. The factor 3600 converts seconds into hours, so T times 3600 is the number of tokens the service can produce in one hour. Dividing the hourly price by that number gives the cost of one token, and multiplying by one million gives the cost per million tokens.

Hourly hardwareprice2 USD per hourTokens generated perhour100 tokens per second times3600 equals 360,000 tokensCost per output tokenabout 0.00000556 USDCost per 1M outputtokensabout 5.556 USDdivided by tokens per hourprice divided by tokensscaled to one million
How the hourly hardware price, the tokens generated per hour, and the cost per token chain together to give the cost per million output tokens, using the source's example of 2 USD per hour at 100 tokens per second.

Applying the formula to the source's example: the hardware costs 2 USD per hour and generates 100 output tokens per second. That is 360,000 tokens per hour. The cost of one token is 2 divided by 360,000, which is about 0.00000556 USD. Scaled to one million tokens, the cost is about 5.556 USD per 1M output tokens.

Why Higher Throughput Can Hurt Responsiveness

Like many software systems, AI applications face a trade-off between latency and throughput. Techniques such as batching can raise throughput, but they tend to lengthen latency. Each user waits a little longer so that the service as a whole finishes more work. The source reports that a team deploying generative AI products found it was not unusual to double or triple throughput, provided they accepted worse TTFT and TPOT figures. TTFT and TPOT are the two latency measures the source uses: the wait before a response begins, and the pace of the response once it starts.

Tracing One Request Through Both Counts

Follow a single request from arrival to its final count. The request is served, its output tokens are generated, and it finishes. At the moment it finishes it is counted in throughput, whatever its speed. Goodput asks one more question: did the request also meet the stated objectives? Only requests that pass that check are counted in goodput.

Request arrivesOutput tokensgeneratedRequest finishescounted in throughputMeets TTFT at most200 ms and TPOT atmost 100 msCounted in goodputmeets the objectivesThroughput onlymisses a targetservedcompletescheck targetsyesno
A request that finishes is always counted in throughput. It is counted in goodput only when it also meets the TTFT and TPOT targets of the stated objectives.

Goodput Counts Only Requests That Meet the Target

The key difference from throughput is which requests are counted. Throughput counts every request that finishes. Goodput counts only the finished requests that also meet the stated objectives, which makes it a stricter measure. A service level objective, often called an SLO, is the set of targets the service promises to meet.

Definition

Goodput is the rate of requests that finish and satisfy the service level objectives, usually expressed in requests per second or requests per minute. It is always less than or equal to throughput measured in requests, because every request counted in goodput is also counted in throughput.

Consider an application whose objectives are a TTFT of at most 200 ms and a TPOT of at most 100 ms. If the service completes 100 requests per minute but only 30 of them meet both targets, its goodput is 30 requests per minute, even though its throughput in requests is 100 per minute. The diagram below places the two readings side by side.

Finished requests100 req per minuteFinished and ontarget30 req per minuteMissed a target70 req per minutemeets both targetsmisses at least one
The same service viewed two ways: throughput counts all 100 completed requests per minute, while goodput keeps only the 30 that meet both latency targets.

The source gives a larger-scale version of the same point. If a service completes 10 requests per second but only 3 of them satisfy the SLO, its goodput is 3 requests per second. The gap between the two numbers, here 7 requests per second, is the portion of the service's output that users would experience as too slow. A service can look productive on its throughput line while most of its finished work misses the targets that users care about.

Rule

Mistakes Beginners Make With These Measures

  • Common mistake

    Treating high throughput as proof of a good user experience

    What it looks like

    A service completes 100 requests per minute, so it seems to be performing well.

    Why it fails

    Throughput counts every finished request, including requests whose users waited too long for a response.

    Do this instead

    Check goodput, which counts only the requests that meet the latency targets, alongside throughput.

  • Common mistake

    Comparing a token rate with a request rate as if they were the same unit

    What it looks like

    Writing that 100 tokens per second equals 100 requests per second.

    Why it fails

    Tokens count generated text and requests count finished jobs. One request usually produces many tokens.

    Do this instead

    State the unit every time, and convert only with a stated average tokens-per-request figure.

  • Common mistake

    Forgetting to convert hours into seconds or minutes

    What it looks like

    Dividing a 2 USD hourly price by 100 tokens per second without multiplying by 3600.

    Why it fails

    The hourly price covers an hour, while the throughput covers a second, so the time units do not match.

    Do this instead

    Convert the throughput into tokens per hour first, as in the formula, before dividing the hourly price.

  • Common mistake

    Counting requests that missed a target in goodput

    What it looks like

    Reporting 100 requests per minute as goodput when only 30 met both targets.

    Why it fails

    Goodput is defined to count only finished requests that satisfy the objectives.

    Do this instead

    Report goodput as 30 requests per minute in this example.

  • Common mistake

    Expecting one universal throughput target to apply everywhere

    Why it fails

    The source states that a good figure depends on the model, hardware, and workload.

Checking Your Goodput Reasoning

What do you think happens?

A different service completes 60 requests per minute. 45 of those requests meet the SLO. What is its goodput in requests per minute, and how many requests are excluded from the count?

Reveal answer
Answer:

Goodput is 45 requests per minute, and 15 requests are excluded because they finished without meeting the SLO.

Goodput counts only the finished requests that satisfy the objectives. 60 minus 45 leaves 15 requests that are counted in throughput but not in goodput.

MEDIUM

Using the same hardware as the source example, a service costs 2 USD per hour and generates 50 output tokens per second instead of 100. Work out the cost per 1M output tokens by following the chain: tokens per hour first, then cost per token, then cost per million. Then state whether the cost per token goes up or down compared with the 100 tokens per second case.

Hints
  • Multiply 50 tokens per second by 3600 to get tokens per hour.
  • Divide the 2 USD hourly price by that number to get the cost of one token.
  • The cost per token should be about double the 100 tokens per second case, because the throughput is halved.

Key Takeaways

  • Throughput measures the output tokens per second an inference service generates summed across all users, and it can also be reported as completed requests per second or per minute.
  • Cost per unit of output falls as throughput rises, because the same hourly hardware price is spread over more tokens; for example, 2 USD per hour at 100 tokens per second gives about 5.556 USD per 1M output tokens.
  • Throughput can rise through techniques such as batching while latency lengthens, so throughput alone can hide a poor user experience.
  • Goodput counts only the finished requests that meet the service level objectives, so 100 requests per minute with 30 on target gives a goodput of 30 requests per minute.

Related concepts

More concepts starting with C