Design Review for a Global AI App: Scoring Cost, Latency and Availability in One Table and Saying the Trade-off
A support app serves agents in India, Europe and US East. The brief becomes p95 first token under 1,000 ms, 99.95% a month and 300 units. One US region fails twice (1,140 ms, 259 min down); Frankfurt plus a second LLM provider and a warm standby passes all three at 275 units, while active-active is better but 170 units dearer.
What you will learn
- Turn a brief like fast, always up and not too expensive into three numbers you can review
- Compute the worst user's first-token time from server time plus three round trips
- Multiply availability for parts in a row and add nines with parts side by side
- Score several designs in one table, pick one, and say what it gives up
Before you start
- Where Time Goes in an LLM Request
- Multi-Region: Active-Passive vs Active-Active
In this article we sit in a design review for a global AI app and answer one question with three numbers: latency, availability and cost. They pull against each other. The job is to find the balance and say it out loud.
All figures are example numbers from one small script, review.py. There are no real prices in it, only cost units.
The design question
TicketHub is a support-ticket app with an AI assistant that drafts replies. Support agents work in three places: India, Europe and the US East coast. The business brief says the app must be fast, always up, and not too expensive.
You can't review adjectives, so turn each one into a number:
| Brief | Number |
|---|---|
| Fast | p95 time to first token under 1,000 ms, for every agent |
| Always up | 99.95% availability a month |
| Not too expensive | At most 300 cost units a month |
99.95% sounds like a lot. A month has 43,200 minutes, so it allows only 21.6 minutes of downtime. A requirement you cannot measure cannot be reviewed.
The review recipe
- Numbers. Done above.
- Options. Two or three real designs, not ten.
- Score. Every option measured on all three numbers, in the same table.
- Decide. Pick one, and say what the decision gives up.
The rule that makes it work: same table for every option.
The starting design: one region, one provider
Most teams ship this first: one region on the US East coast, one LLM provider behind it, and requests from all three places. The line from India is the longest by far.
Latency: distance sets the floor
The formula is server time plus network. At the server, slow requests get their first token in 750 ms (p95). India to US East is about 13,000 km. Light in fibre covers about 200 km per millisecond, so one round trip is 130 ms. A new session needs three round trips (TCP, TLS and the request itself): 390 ms.
KM_PER_MS = 200 # light in fibre, about
SERVER_TTFT_MS = 750 # p95 first token at server
COLD_RTTS = 3 # TCP + TLS 1.3 + request
def first_token(user, region):
rtt = 2 * km(user, region) / KM_PER_MS
return SERVER_TTFT_MS + COLD_RTTS * rtt
--- latency floor
500 km rtt 5 ms x3 15 ms
6500 km rtt 65 ms x3 195 ms
13000 km rtt 130 ms x3 390 ms
--- A one region
India -> US East 1140 ms
Europe -> US East 945 ms
US East -> US East 765 ms
Europe and US East are fine, but the SLO says every agent, so the worst user decides: India at 1,140 ms, over the line. (Why first token is the right clock for a chat reply is covered in Where Time Goes in an LLM Request.)
Move the region to the middle
Before adding anything, just move the region to Frankfurt, which sits between India and the US. India is now 6,500 km away and gets 945 ms, US East also gets 945 ms, and Europe drops to 765 ms. Every user is under the line, and the region costs the same. Placement can fix latency without spending more.
Availability: layers in a row multiply
A request needs two things to work, and it needs both: the region (up 99.9% of the time) and the LLM provider (up 99.5% in our example). Parts in a row multiply:
0.999 x 0.995 = 99.40% -> 259 minutes down a month
That's against a budget of 21.6. Chain two parts and you inherit both outages. The weakest one, here the provider, sets the number.
A gateway and a second provider
Fix the weakest part first. Put a small gateway in front of the model calls, with a second provider from another vendor behind it. If one is down, the gateway sends the call to the other, so now both must fail at the same time. Parts side by side add nines:
def parallel(a, n):
return 1 - (1 - a) ** n
llm x1 99.5000% llm x2 99.9975%
The total goes from 99.40% to 99.898%, and downtime drops from 259 minutes to 44.3. The gateway costs 5 units. It still misses 21.6 minutes, but it is the cheapest big win in the whole review: 5 units buy back about 215 minutes. Building that gateway is the subject of Fallback models for an LLM app.
A second region, active-passive
Now the region is the weak part. Add a warm standby in US East that runs small, with the data copied to it all the time. When Frankfurt goes down, traffic moves to the standby, and in our example that failover takes 15 minutes. A 43-minute region outage now costs only 15.
--- B active-passive
worst 945 ms avail 99.963% down 16.1 min
cost 275 units pass (True, True, True)
B in failover, India: 1140 ms
16.1 minutes a month, under budget. The price: during a failover, India is served from US East again and waits 1,140 ms. A standby turns a long outage into a short failover. The mechanics (RTO, RPO, write homes) are in Multi-Region: Active-Passive vs Active-Active.
Cost on one bar
The script counts each option in units: a full region is 100, a standby 40, each data copy 10, tokens 120 and the gateway 5.
# cost units per month (example figures)
FULL, STANDBY, REPL, TOKENS, GATEWAY = (
100, 40, 10, 120, 5)
def cost(full, standby, n_llm):
extra = full + standby - 1
gw = GATEWAY if n_llm > 1 else 0
return (full * FULL + standby * STANDBY
+ extra * REPL + TOKENS + gw)
The scorecard
Everything goes into one table, the same for every option:
--- A2 move+gateway
worst 945 ms avail 99.898% down 44.3 min
cost 225 units pass (True, False, True)
--- C active-active
India -> India 765 ms
Europe -> Frankfurt 765 ms
US East -> US East 765 ms
worst 765 ms avail 99.995% down 2.1 min
cost 445 units pass (True, True, False)
C over B: +170 units, -180 ms, -14.0 min
passes all three: ['B active-passive']
| Option | Worst first token | Availability | Down / month | Cost | Passes |
|---|---|---|---|---|---|
| A: one region, US East | 1,140 ms (fail) | 99.401% (fail) | 259.0 min | 220 | 1 of 3 |
| A2: Frankfurt + gateway | 945 ms | 99.898% (fail) | 44.3 min | 225 | 2 of 3 |
| B: active-passive | 945 ms | 99.963% | 16.1 min | 275 | 3 of 3 |
| C: active-active, 3 regions | 765 ms | 99.995% | 2.1 min | 445 (fail) | 2 of 3 |
Only B gets three ticks. Active-active is better on every number, but it costs 170 units more to buy 180 ms and 14 minutes. Active-passive passes all three; active-active is better, but not 170 units better.
Change one number
A good review also asks what happens if one number moves. Say finance cuts the budget to 250 units:
budget 250, latency ok: ['A2 move+gateway']
Now B costs too much and no option passes all three. The best you can afford is A2: latency fine, 225 units, but 44 minutes down a month against 21.6 allowed. Don't hide it. Take two clear paths back to the business: accept about 99.9% (44 minutes a month), or raise the budget to 275. When no option passes, the review becomes a question for the business.
Saying it in the review
Four sentences, in this order, in a design review or an interview:
Requirement: p95 first token under 1,000 ms, 99.95% a month, 300 units.
Choice: Frankfurt active, a warm standby in US East, and two LLM providers behind a gateway.
Score: 275 units, 945 ms for the worst user, 16 minutes of downtime a month.
Trade-off: during a failover India waits 1,140 ms, and we look at it again when India traffic grows.
Numbers, choice, score, trade-off. That order is what makes the answer sound like an architect.
Common mistakes
- Reviewing adjectives. "Fast" can't fail a check. "p95 TTFT under 1,000 ms for every agent" can.
- Averaging users. The SLO says every agent, so score the worst one.
- Counting one round trip. A new session pays three (TCP, TLS, request).
- Adding regions before fixing the weakest link. Here the provider cost 259 minutes and a 5-unit gateway fixed most of it.
- Picking the best option, not the one that passes. Active-active wins every number and still fails the budget.
Recap
| Number | How to score it |
|---|---|
| Latency | Worst user: server time + 3 round trips on a new session |
| Availability | Parts in a row multiply; parts side by side add nines |
| Cost | Count the regions; tokens follow traffic, not design |
| Decision | The option that passes all three, plus what it gives up |
For the portability side of the same app, see Cloud-Agnostic Architecture: The Portability Layers.
Try it yourself
Keep option B, but say the failover takes 30 minutes instead of 15. Does it still pass 99.95%? Then try a cheaper path: what if the second LLM provider is dropped from B? Work out availability and cost with the formulas above and decide which option you would take to the business.
Related course on Udemy
The Python Architect Masterclass: Full Stack to AI Engineer
Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)Related posts
Fallback Models for an LLM App: A Chain That Checks Region and Fit, Flags Degraded Answers and Gets Rehearsed
When the main model goes down, the backup has to be allowed to take the data, able to read the whole request and tested before the bad day. A simulated four-model chain for an EU customer: a 6,000-token request lands on mid-eu, flagged degraded; a 10,000-token request is served by nobody, on purpose.
Back Pressure for LLM Traffic: Bound the Queue, Give Chat Its Own Lane, Count Tokens, Cancel When the Caller Leaves
A bulk upload buries the chat. In a small simulation, one shared queue grows to 199 waiting and the middle chat answer takes 80.2 s. A bound plus a chat lane brings it to 0.35 s while 178 bulk jobs are told to retry in 10 s, and cancelling abandoned calls saves 21,000 wasted tokens.
Load Balancing LLM Traffic: Count the Work, Weigh the Prefix Cache, Check Real Health, Drain Before Deploys
Six GPU replicas, two at 95% and four at 30%: round robin counts requests, and requests aren't equal. In a small simulation, least outstanding requests cuts p95 from 6.52 s to 3.05 s, prefix affinity lifts cache hits to 95% but pushes p95 to 11.45 s, a real health check takes errors from 48 to 2, and draining cuts 0 answers instead of 4.
A Message Queue for Document Ingestion: At Least Once, Leases, an Idempotent Consumer and a Dead Letter Queue
A queue doesn't lose a document, but it can hand one out twice. In a small simulation, a worker crash makes document two go from 3 to 6 chunks and the index holds 11 when the documents hold 8. An idempotent consumer brings it back to 8 with the same two deliveries, and a limit of three tries moves a poison file to a dead letter queue.
