# Does shadow testing double your bill? Budget the overlap

URL: https://infro.io/blog/does-shadow-testing-double-your-bill-budget-the-overlap
Author: INFRO Editorial (https://infro.io/blog/editorial)
Publisher: INFRO
Published: 2026-11-22
Last modified: 2026-11-22
Last reviewed: 2026-11-22 (next review due 2027-05-21)
Topic: Cost and FinOps
Format: Analysis

> Shadow testing adds roughly sample rate × the candidate's cost per request × request count, plus one judge call per scored answer. It doubles the bill only at 100% mirroring to an equally priced model, so size the sample to the decision, cap it on its own key, and time-box it.

Key takeaways:
- Extra spend from a shadow test is sample rate × the candidate's cost per request × request count, plus judge calls; it only doubles the bill at 100% mirroring to a model that costs the same per request.
- Size the sample to the number of judged answers the decision needs, not to a round percentage of traffic; at high volume a few percent is usually far more than needed.
- Price the candidate per request with its own token counts and output behaviour, not with production's token totals and a new rate card.
- Judge calls are a second meter and can rival the candidate's own cost, so cap them separately.
- Run shadow traffic on its own project and key with a lifetime spend limit, a single-target route with no fallback to production, and a stop switch in code.
- End the overlap on whichever comes first: enough judged answers per slice, the cap, or a calendar date written down before you start.

## The short answer: it depends on three multipliers

Shadow testing sends a copy of a live request to a candidate model, discards the answer (or scores it), and leaves the user on the production model. Whether that doubles your bill is arithmetic, not a rule. The extra spend is the share of traffic you mirror, times what the candidate costs per request, times how many requests there are, plus whatever you pay to judge the answers.

If you mirror 100% of requests to a model that costs the same per request, the overlap costs as much as production for as long as it runs. If you mirror 5% for two weeks, it is a small line item. If the candidate costs twice as much per request and you mirror everything, you pay triple, not double. The three levers are sample rate, per-request price gap and duration.

This article costs those levers out. It does not repeat how to replay traffic safely, covered in [can you replay production traffic to test a new model safely](https://infro.io/blog/can-you-replay-production-traffic-to-test-a-new-model-safely), or how to budget an offline eval run, covered in [what should an eval run cost](https://infro.io/blog/what-should-an-eval-run-cost-budgeting-your-evaluation-spend). The question here is the live overlap: how much extra to plan for, how to make it a hard ceiling, and when to stop.

## Price one shadow request, not one token

The usual mistake is to take last month's token totals, apply the candidate's rate card and call that the shadow cost. Last month's totals came from the current model's tokenizer, and the candidate will cut the same text into a different number of tokens. INFRO's tokenizer method separates the bill ratio of a model switch into rate, tokenizer, behavior, cache and threshold factors, and says to measure each separately.[1] For a shadow test you need all five, applied to one request:

```text
shadow_request_cost = T_in  × r_in  × P_in
                    + T_out × r_out × b × P_out

T_in, T_out   average input / output tokens per production request
r_in, r_out   candidate-vs-current token ratios for the same text
b             behavior factor: longer answers, reasoning output
P_in, P_out   the rates your own contract carries for the candidate
```

Take `r_in` and `r_out` from the candidate's own counting method on real payloads, per workload slice.[1] The behavior factor `b` cannot be counted in advance, because the candidate has not generated anything yet; it comes from a small trial run, and FinOps guidance on estimating lists trial runs in non-production environments as a technique for exactly this.[2] Use the rates your contract carries, not the list price, if they differ. INFRO's custom rates let estimated cost use negotiated rates before the vendor's list rate.

Two shadow-specific effects sit outside the formula. First, a candidate's prompt cache starts cold, so early shadow requests pay full input rates and any cache-write premium; the tokenizer method treats cache behaviour as its own factor for this reason.[1] Second, mirrored requests that carry tool definitions bill those definitions as input on the candidate too, and a shadow run must never execute the tools' side effects.

## Total the overlap: sample rate, duration and the judge

With a per-request cost, the overlap is:

```text
extra = N × s × shadow_request_cost          # candidate calls
      + N × s × j × judge_call_cost          # scoring
```

`N` is production requests in the window, `s` the fraction mirrored and `j` the fraction of shadow answers you judge. The judge is a second meter. An LLM-as-judge call reads the input, the answer and the rubric, so its input is larger than the call it judges. INFRO's experiment estimate shows the effect: in the documentation's sample, the judge's estimated cost is $2.10 against $1.84 for the current-model variant and $6.07 in total, so judging is about a third of the run.[3] Budget it as its own line.

> **Example: Illustrative overlap for a 14-day shadow test**
> All figures here are made up to show the method; they are not vendor rates. Assume 2 million production requests a month (about 933,000 in 14 days), 1,800 input and 400 output tokens per request, and production rates of $2 per million input tokens and $8 per million output tokens. That gives $0.0068 a request and about $13,600 a month, or about $6,350 over the 14 days.
> 
> The candidate is priced at $3 and $12 per million tokens, tokenizes input 1.2 times as large, and writes 1.5 times the output tokens once behavior is included. That is $0.01368 a request, about twice production's per-request cost. The judge costs $0.0033 a call and scores every shadow answer.
> 
> | Sample rate | Shadow requests | Candidate cost | Judge cost | Extra total | Extra vs production over the 14 days |
> | --- | --- | --- | --- | --- | --- |
> | 1% | 9,333 | $128 | $31 | $159 | 2.5% |
> | 5% | 46,667 | $638 | $154 | $792 | 12.5% |
> | 20% | 186,667 | $2,554 | $616 | $3,170 | 49.9% |
> | 100% | 933,333 | $12,768 | $3,080 | $15,848 | 249.7% |
> 
> Full mirroring here costs two and a half times production's spend for the window, because the candidate costs about twice as much per request and the judge adds a further quarter.

The table shows why "double" is the wrong frame. The multiplier is `s` times the price ratio, and the judge sits on top.

## Size the sample to the decision, not to a round percentage

A percentage of traffic is the wrong unit. What you need is a number of judged answers per workload slice, enough to tell the candidate from production at the margin you care about. The companion article on [how many eval cases you need before switching models](https://infro.io/blog/how-many-eval-cases-do-you-need-before-switching-models) covers that count. Convert it into a sample rate:

```text
s = judged_answers_needed / (slice_traffic_in_window × j)
```

At the volume in the example, 2,000 judged answers needs well under 1% of traffic over two weeks. A 5% sample would give 46,000, far more than the decision needs. The exception is rare slices: a slice that is 0.5% of traffic gets 5% of 0.5% of requests under uniform sampling, so oversample it by sampling per slice at different rates.

Pick the sampled requests deterministically, by hashing a request id, so the same request is always in or out and retries don't draw a second ticket. Random sampling per attempt inflates the effective rate when your client retries.

## Make the cap hard: separate project, key, route and a stop in code

A budget alert is not a cap. The aim is a test that cannot spend more than a number you chose, however the sampling code behaves. Four layers help, from the outside in.

1. **A dedicated project and gateway key for shadow traffic.** INFRO key limits can be daily, weekly or monthly, or a lifetime ceiling that never resets, and key limits always block.[4] A lifetime ceiling on the shadow key matches a test with one end date. Project and member budgets can alert or block too; an organization's monthly target only alerts, and only the owner sets the organization hard cap.[4]
2. **A blocking limit is conservative on purpose.** A blocking budget admits a request only if its worst-case estimated cost fits the room left, counting reservations held by requests in flight, and the worst case uses the most expensive model and provider the request could fall back to. It is an upper bound on INFRO's estimate, not on the provider's invoice, and near the limit a request can be refused briefly for room that is reserved but unspent.[4] Set the ceiling above your estimate with headroom, and expect the test to stop slightly early.
3. **A single-target shadow route with no fallback.** On a route, any upstream failure before the response starts moves to the next target, and a route can retry the same target up to three times, immediately and with no backoff.[5] For a shadow route that is the wrong default: a failover to the production model bills production rates for a call you meant to be a candidate call, and retries multiply the bill during an incident. Give the shadow route one target and zero retries.
4. **A stop switch in your own code.** The key limit refuses requests, but your sampler keeps firing them. Catch the refusal and stop sampling.

```python
import hashlib
import threading
from openai import OpenAI, APIStatusError

shadow = OpenAI(base_url="https://api.infro.io/v1", api_key=SHADOW_KEY)
stopped = threading.Event()
RATE = 0.01  # from the sizing step, not a round number

def in_sample(request_id: str, rate: float) -> bool:
    h = int(hashlib.sha256(request_id.encode()).hexdigest()[:8], 16)
    return h / 0xFFFFFFFF < rate

def shadow_call(request_id: str, messages: list, slice_name: str) -> None:
    if stopped.is_set() or not in_sample(request_id, RATE):
        return
    try:
        shadow.chat.completions.create(
            model="shadow-candidate",   # a one-target route, no retries
            messages=messages,
            max_tokens=800,             # bounds the behavior factor
            extra_body={"metadata": {
                "workflow": "shadow-candidate",
                "feature": slice_name,
                "tags": {"test": "migration-2026-11"},
            }},
        )
    except APIStatusError as e:
        if e.status_code == 402:  # confirm the budget-refusal status in the errors reference
            stopped.set()
```

Run `shadow_call` off the request path, in a background worker, so the user's latency never depends on the candidate. `max_tokens` bounds the one factor you could not count in advance. If you attach attribution metadata, group by it later: INFRO's `workflow`, `feature` and `user_id` keys are stored on the request row and can be grouped in usage reports.[6]

## Cap the judge on its own meter

Judging is where an uncapped test most often overspends, because it scales with shadow volume and nobody has put a limit on it. INFRO's evaluators run a rubric on a model of your choosing, judge a sampled share of live traffic, and require a `monthly_spend_limit` in estimated provider cost; when judge calls reach it, live judging pauses until the next month.[7] An evaluator can be limited to one project, so pointing it at the shadow project judges shadow answers only, and judging starts after the response is sent, so it never slows the judged request.[7] Judge calls run as the key that made the judged request, so the shadow key's own limits apply to them as well.[7]

The judge also counts as requests. The experiments estimate includes one judge call per evaluator on every answer in its request count and shows how much of the monthly allowance the run uses.[3] Do the same sum for a live test: shadow calls plus judge calls, against your request allowance and, separately, against the candidate provider's own rate limits. Your provider accounts keep their own quotas, and INFRO adds no shared pool of capacity.[8] A 20% shadow can push a new candidate model into its rate limit while production on another model is fine.

If you want a bounded, priced test first, an INFRO experiment does the dry-run estimate before it starts, and a started experiment takes a spend cap at least equal to the estimate.[3] Run that on a dataset, then move to live shadow only for the drift question a dataset cannot answer.

## Decide when the overlap ends before it starts

A shadow test with no end date becomes a second production system. Write the stopping rule into the plan, with three triggers and whichever fires first ends it:

- **Evidence:** the judged answers per slice reached the number you sized for, and the comparison no longer moves when more arrive.
- **Spend:** the cap was reached. Treat this as a result: if the cap is hit before the evidence target, the plan underestimated `b` or the price ratio, and you re-plan rather than raise the cap quietly.
- **Calendar:** a date, set at the start, usually one to two weeks, long enough to cover a weekly traffic cycle.

Weigh the marginal cost of a day against the value of waiting. If the candidate has a lower rate and production's per-request cost is known, each extra overlap day delays the lower rate by a day and costs `N_per_day × s × shadow_request_cost` besides. When the daily overlap cost approaches the daily gap you hope to capture, the test is more expensive than the decision.

Close the loop with measured figures. INFRO's tokenizer method says to treat the pre-switch factor as a forecast and replace it with a factor computed from provider-reported usage after a canary.[1] FinOps guidance describes the same discipline at its most mature level: each estimate carries a documented counterfactual forward to be checked against what happened, so the next estimate is better.[2] Query the shadow workflow's actual estimated cost with `GET /v1/usage`, which can group by workflow, feature, project and key,[9] compare it with your plan, and record the gap. Then reconcile against the provider's own invoice, since the estimate is the gateway's figure, not the bill.

## What to put in the plan

A one-page plan lets finance approve the overlap without a meeting. It needs the per-request cost with its five factors, the sample rate derived from judged answers needed, the judge as a separate line, the cap and where it is enforced, the end triggers with a date, and the owner who reads the usage report on day three, not day fourteen. The overlap becomes a bounded, attributed line in the migration budget instead of a surprise on the next invoice.

## Questions

### Does a shadow request count against my INFRO request allowance?

Yes. A shadow call sent through the gateway is a request like any other, and so is each judge call. INFRO's experiment estimate lists the request count and how much of the monthly allowance a run would use, which is the same arithmetic to apply to a live shadow test.[3]

### Should I shadow-test or replay a saved dataset?

Replay a dataset when you need a bounded, repeatable cost and a fixed comparison. Shadow live traffic when you need the candidate to see today's real mix, including rare inputs a dataset lacks. Many teams replay first because its cost is known before it starts, then shadow a small sample to check for drift.

## Sources

1. Switching models changes the tokenizer: how much does your bill move? — INFRO Blog. https://infro.io/blog/switching-models-changes-the-tokenizer-how-much-does-your-bill-move (accessed 2026-11-22)
2. Planning & Estimating FinOps Framework Capability — FinOps Foundation. https://www.finops.org/framework/capabilities/planning-estimating/ (accessed 2026-11-22)
3. Experiments — Observability — INFRO Docs. https://infro.io/docs/observability/experiments (accessed 2026-11-22)
4. Spend controls — Organizations — INFRO Docs. https://infro.io/docs/org/spend-controls (accessed 2026-11-22)
5. Smart routing — Features — INFRO Docs. https://infro.io/docs/features/routing (accessed 2026-11-22)
6. Cost attribution — Cost & finance — INFRO Docs. https://infro.io/docs/features/attribution (accessed 2026-11-22)
7. Evaluators — Observability — INFRO Docs. https://infro.io/docs/observability/evaluators (accessed 2026-11-22)
8. Rate & spend limits — API reference — INFRO Docs. https://infro.io/docs/api/limits (accessed 2026-11-22)
9. Usage analytics — Observability — INFRO Docs. https://infro.io/docs/observability/analytics (accessed 2026-11-22)
