Markdown Editor

LLM Inference Serving and Vector Search Platform Design Template

Gateway, router, continuous batching, paged KV cache, GPU memory and throughput math, TTFT/TPOT SLOs, autoscaling, quantization, HNSW/IVF, cost per token

架构与系统设计完整PagedAttention (Kwon et al., SOSP 2023)designllminferenceservingmath

使用方法: Use it when building a shared platform that serves LLMs and vector search to several teams. Fill the workload assumptions (3.1) with measured prompt and output lengths first, then size the KV cache before compute. The main pitfall is planning from GPU datasheet peaks and GPU utilisation instead of measured tokens per second, queue depth and KV cache usage.

预览

System Design: [LLM inference platform name]

Reference design for a shared platform that serves large language models and vector search to internal product teams. It covers the request flow (gateway, router, model servers), continuous batching, the KV cache and paged attention, prefill versus decode, GPU memory sizing, latency SLOs (time to first token and time per output token), GPU autoscaling, model routing and fallback, quantization, multi-tenancy and rate limits, the vector index (HNSW and IVF), the embedding pipeline and cost per million tokens. It is the platform underneath applications such as the one in the RAG System Design Template (ai-data/rag-system-design). It follows the structure of the System Design Document template and is pre-filled with a worked design to adapt. Replace every [bracketed] value and every row marked Example; all numbers are illustrative examples, not benchmarks.

Document control

FieldValue
Document ID[SDD-LLM-001]
System / feature[LLM inference and vector search platform]
Version[0.1]
Status[Draft / In review / Approved / Implemented / Superseded]
Author(s)[@author]
Reviewers[@reviewer-1], [@reviewer-2]
Last updatedYYYY-MM-DD
Classification[Internal]
Models in scope[Model names, versions and licences]
Related[RAG system design], [LLM observability spec], [Capacity plan], [AI risk assessment]

Approvals

RoleNameDecisionDate
Tech lead, ML platform[@name][Approved / Changes requested]YYYY-MM-DD
Staff / principal engineer[@name][Decision]YYYY-MM-DD
SRE / operations[@name][Decision]YYYY-MM-DD
Security and privacy[@name][Decision]YYYY-MM-DD
FinOps / budget owner[@name][Decision]YYYY-MM-DD

Revision history

VersionDateAuthorChange summary
0.1YYYY-MM-DD[@name]First draft for design review
0.2YYYY-MM-DD[@name]Example: Added FP8 variant and routing of short prompts to the small model
0.3YYYY-MM-DD[@name]Example: Replaced flat vector index with HNSW plus scalar quantization
1.0YYYY-MM-DD[@name]Example: Approved

Contents

1. Overview

1.1 Problem statement

[Example: Six product teams each run their own model server on dedicated GPUs. Average GPU utilisation is 18%, yet two teams hit out-of-memory errors at peak because long prompts exhaust the KV cache. There is no shared rate limiting, so one batch job raised time to first token for the support assistant from 0.6 s to 9 s. Each team also runs its own vector database, with recall nobody has measured.]

1.2 Proposed solution

[Example: A single platform behind an OpenAI-compatible gateway. The gateway authenticates tenants, applies token-based rate limits and passes requests to a router that picks a model pool by model name, prompt length, priority class and pool health. Each pool runs replicas of an inference engine with continuous batching and a paged KV cache (in the style of vLLM PagedAttention). Pools autoscale on queue depth and KV cache usage, not CPU. A separate retrieval service offers embedding and vector search over HNSW indexes per collection. Usage is metered per tenant in tokens and converted to cost per million tokens for chargeback.]

1.3 Decisions requested from reviewers

IDQuestionRecommended optionSection
Q-01Example: One shared fleet or per-team GPUs?Shared pools per model, isolation by priority class and quotas7.8, 10
Q-02Example: Precision for the large model?BF16 weights at launch; FP8 pool after evaluation parity is shown7.7
Q-03Example: Autoscaling signal?Pending requests and KV cache usage per replica7.6
Q-04Example: Fallback when the large pool is saturated?Route low-priority traffic to the small model; never silently for high priority7.5
Q-05Example: Vector index type?HNSW with int8 scalar quantization; IVF-PQ for the archive collection7.9
[Q-nn][Question][Option][Section]

2. Requirements

2.1 Functional requirements

IDRequirementPriority
FR-01Example: Chat and completion endpoints with streaming responsesMust
FR-02Example: Serve at least two model sizes (large 70B-class, small 8B-class)Must
FR-03Example: Per-tenant API keys, quotas in tokens per minute and requests per minuteMust
FR-04Example: Priority classes: interactive, standard, batchMust
FR-05Example: Embedding endpoint and vector search with metadata filtersMust
FR-06Example: Usage metering per tenant, model and priority classMust
FR-07Example: Model version pinning and gradual rollout of new versionsShould
FR-08Example: Prefix caching for shared system promptsShould
FR-09Example: Offline batch inference with a 24-hour completion windowCould
[FR-nn][Requirement][Must / Should / Could]

2.2 Non-functional requirements

IDQualityTargetMeasured as
NFR-01Time to first token (TTFT), interactiveExample: p95 at or below 1.0 s for prompts up to 4 000 tokensGateway timing, first streamed byte
NFR-02Time per output token (TPOT), interactiveExample: p95 at or below 50 msInter-token interval at the gateway
NFR-03AvailabilityExample: 99.9% monthly for interactive classSLO on successful completions
NFR-04IsolationExample: Batch load cannot raise interactive TTFT p95 by more than 20%Load test with mixed tenants
NFR-05Vector searchExample: recall at 10 at or above 0.95, p99 at or below 50 ms at 2 000 queries/sRecall test set; service timing
NFR-06CostExample: Within budget per million tokens in 3.6Monthly chargeback report
NFR-07Data handlingExample: Prompts and outputs not stored by default; tenant opt-in logging with 30-day retentionConfiguration audit
[NFR-nn][Quality][Target][Measurement]

2.3 Out of scope

  • [Example: model training and fine-tuning pipelines]
  • [Example: application-level retrieval logic, prompt design and evaluation (see RAG System Design Template (ai-data/rag-system-design) and LLM Evaluation Plan Template (ai-data/llm-evaluation-plan))]
  • [Example: calls to external hosted model APIs (handled by the gateway as a passthrough, not served here)]
  • [Item deferred, with the release that will take it]

3. Capacity estimation

3.1 Assumptions

All values are Example planning inputs for the large model pool. Replace them with measurements from your engine and hardware.

InputSymbolValueSource
ParametersPP70 billionModel card
Transformer layersLL80Model config
KV heads (grouped-query attention)hkvh_{kv}8Model config
Head dimensiondhd_h128Model config
Bytes per value (BF16)bb2Precision choice
GPUs per replica (tensor parallel)gg47.2
Memory per GPUmm80 GBHardware
HBM bandwidth per GPUBwB_w3.35 TB/sHardware datasheet (peak)
Dense BF16 compute per GPUFF1 000 TFLOP/sRounded datasheet peak
Model FLOP utilisation in prefillηp\eta_p0.4Engine benchmark
Bandwidth efficiency in decodeηd\eta_d0.6Engine benchmark
Peak requests per secondRR20Tenant forecasts
Mean prompt tokensninn_{in}1 500Tenant logs
Mean output tokensnoutn_{out}500Tenant logs
Maximum batch (sequences per step)BB128Engine setting
GPU cost per hourcgc_gUSD 2.50Example contract price

3.2 Weights

Mw=P×b=70×109×2 B=140 GBM_{w} = P \times b = 70 \times 10^{9} \times 2 \ \text{B} = 140 \ \text{GB}

The weights do not fit one 80 GB GPU, so one replica spans g=4g = 4 GPUs (320 GB in total).

3.3 KV cache per token and concurrency

Each layer stores one key and one value vector per KV head per token:

skv=2×L×hkv×dh×b=2×80×8×128×2=327 680 B≈320 KiB per tokens_{kv} = 2 \times L \times h_{kv} \times d_h \times b = 2 \times 80 \times 8 \times 128 \times 2 = 327\,680 \ \text{B} \approx 320 \ \text{KiB per token}

The engine reserves 90% of GPU memory and keeps 8 GB for activations and runtime buffers, leaving for the KV cache pool:

Mkv=0.9×320−140−8=140 GB,Ntok=140×109327 680≈427 000 tokensM_{kv} = 0.9 \times 320 - 140 - 8 = 140 \ \text{GB}, \qquad N_{tok} = \frac{140 \times 10^{9}}{327\,680} \approx 427\,000 \ \text{tokens}

During decode a sequence holds its prompt plus, on average, half its output, so the mean resident length is 1 500+250=1 7501\,500 + 250 = 1\,750 tokens. A full batch of 128 sequences uses

128×1 750×327 680 B≈73.4 GB128 \times 1\,750 \times 327\,680 \ \text{B} \approx 73.4 \ \text{GB}

which fits the 140 GB pool with room for long prompts. The pool could hold about 427 000/1 750≈244427\,000 / 1\,750 \approx 244 average sequences, so with B=128B = 128 the batch limit, not memory, binds for average traffic. Long prompts change that: 128 sequences at the 8 192-token maximum would need about 344 GB, so the scheduler must queue or preempt (7.3).

3.4 Decode and prefill rates per replica

Decode reads all weights plus the batch's KV cache once per step:

tstep≈Mw+Mkv,batchg×Bw×ηd=140+73.4 GB4×3.35 TB/s×0.6≈26.5 mst_{step} \approx \frac{M_w + M_{kv,batch}}{g \times B_w \times \eta_d} = \frac{140 + 73.4 \ \text{GB}}{4 \times 3.35 \ \text{TB/s} \times 0.6} \approx 26.5 \ \text{ms}

So TPOT is about 27 ms (within NFR-02) and decode throughput per replica is

D=Btstep=1280.0265 s≈4 800 output tokens/sD = \frac{B}{t_{step}} = \frac{128}{0.0265 \ \text{s}} \approx 4\,800 \ \text{output tokens/s}

Prefill costs about 2P2P floating-point operations per prompt token:

Frep=g×F×ηp=4×1015×0.4=1.6×1015 FLOP/s,Prate=1.6×10152×70×109≈11 400 prompt tokens/sF_{rep} = g \times F \times \eta_p = 4 \times 10^{15} \times 0.4 = 1.6 \times 10^{15} \ \text{FLOP/s}, \qquad P_{rate} = \frac{1.6 \times 10^{15}}{2 \times 70 \times 10^{9}} \approx 11\,400 \ \text{prompt tokens/s}

A 1 500-token prompt alone takes about 1 500/11 400≈0.131\,500 / 11\,400 \approx 0.13 s to prefill, so the 1 s TTFT target leaves most of the budget for queueing and batching delay.

3.5 Replicas for peak load

Peak demand is R×nin=30 000R \times n_{in} = 30\,000 prompt tokens/s and R×nout=10 000R \times n_{out} = 10\,000 output tokens/s. Treating prefill and decode time as shares of one replica:

U=30 00011 400+10 0004 800≈2.63+2.08=4.71 replica-equivalentsU = \frac{30\,000}{11\,400} + \frac{10\,000}{4\,800} \approx 2.63 + 2.08 = 4.71 \ \text{replica-equivalents}

At a target utilisation of 0.7 to protect latency, 4.71/0.7≈6.74.71 / 0.7 \approx 6.7, rounded up to 7 replicas, plus one for failure and rollout (N+1): 8 replicas, or 32 GPUs at peak.

3.6 Cost per million tokens

At peak the pool costs 32×2.50=8032 \times 2.50 = 80 USD per hour and serves 30 000×3 600=10830\,000 \times 3\,600 = 108 million prompt tokens and 10 000×3 600=3610\,000 \times 3\,600 = 36 million output tokens per hour. Splitting cost by the replica time each phase uses (2.63 and 2.08 of 4.71, so 56% and 44%):

cin=0.56×80108≈0.41 USD per million prompt tokens,cout=0.44×8036≈0.98 USD per million output tokensc_{in} = \frac{0.56 \times 80}{108} \approx 0.41 \ \text{USD per million prompt tokens}, \qquad c_{out} = \frac{0.44 \times 80}{36} \approx 0.98 \ \text{USD per million output tokens}

These are peak-hour figures. Off-peak capacity that cannot be scaled down raises the daily average; publish the monthly figure from metering, not this estimate.

3.7 Vector index memory

ItemCalculationResult
Chunks indexedExample: 100 million
Raw float32 vectors, 768 dimensions100 000 000 x 768 x 4 B307.2 GB
HNSW graph links, M=32M = 32 (64 links on the base layer, 4 B each)100 000 000 x 64 x 4 Babout 25.6 GB
int8 scalar quantization100 000 000 x 768 x 1 B76.8 GB
Product quantization, 96 sub-vectors of 8 bits100 000 000 x 96 B9.6 GB
Embedding ingestExample: 5 million new chunks/day x 400 tokens2 billion tokens/day, about 23 000 tokens/s on average

3.8 Summary

QuantityEstimateDesign consequence
Large model replica4 GPUs, 140 GB weights, 140 GB KV poolTensor parallel within one node
Concurrency per replicaBatch of 128; about 244 average sequences fit in memoryBatch limit set by latency, preemption for long prompts
TPOTAbout 27 msMeets 50 ms target with headroom
Peak replicas8 (32 GPUs)Autoscale between minimum 3 and maximum 10
Cost at peakAbout USD 0.41 per million prompt tokens and USD 0.98 per million output tokensChargeback per tenant
Vector indexAbout 100 GB per 100 million chunks with int8 plus graphMemory-optimised nodes, sharded by collection

4. API design

4.1 Endpoints

Method and pathPurpose
POST /v1/chat/completionsChat completion, streaming with server-sent events
POST /v1/embeddingsEmbed a batch of texts
POST /v1/collections/{id}/queryVector search with filters and top-k
POST /v1/collections/{id}/upsertAdd or replace vectors with metadata
POST /v1/batchesSubmit offline batch inference
GET /v1/modelsList models, versions and limits available to the tenant
GET /v1/usage?from=&to=Tokens and cost per model and class

4.2 Request example

The tenant names a model alias, not a pool. The router maps the alias to a pinned version and pool; the response reports the version actually used.

POST /v1/chat/completions
Authorization: Bearer [tenant key]
X-Priority: interactive
Content-Type: application/json

{"model": "assistant-large", "stream": true, "max_tokens": 600, "messages": [{"role": "system", "content": "[system prompt]"}, {"role": "user", "content": "[question]"}]}

4.3 Limits and errors

StatusProblem typeMeaning
400context-too-longPrompt plus max_tokens exceeds the model's context window
429token-rate-exceededTenant tokens per minute exhausted; Retry-After set
503capacity-unavailablePool saturated and no permitted fallback; Retry-After set
504deadline-exceededRequest deadline passed before first token

Rate limits count both prompt and output tokens. The gateway reserves prompt_tokens + max_tokens at admission and refunds the unused part on completion, so large max_tokens values cost quota until the stream ends.

5. Data model

5.1 Entities

Configuration entities (tenants, quotas, models, pools) are small and audited; usage records and vectors are high-volume and partitioned.

5.2 Storage choices

DataStoreNotes
Tenants, keys, quotas, routing tableRelational database, cached in the gatewayChanges propagate within 30 s
Rate limit countersIn-memory store with atomic scriptsSame pattern as Rate Limiter System Design (architecture/design-rate-limiter)
Usage recordsEvent stream to the analytics warehouseNever on the request path
Model weightsObject storage plus node-local cachePre-pulled on node start to cut cold start
Vector indexesVector database nodes, sharded by collectionSnapshots to object storage
Prompt and output logsOff by default; tenant opt-in store with retention policySee NFR-07

6. High-level design

ComponentResponsibilityScales by
Inference gatewayAuth, quotas, streaming proxy, meteringHorizontally (CPU)
Model routerMap alias to pool; choose by length, priority, health; fallbackHorizontally
Pool queuesPer-pool, per-priority queues with deadlinesOne per pool
Model replicasInference engine with continuous batching and paged KV cacheGPUs, per pool
Retrieval serviceQuery embedding, vector search, filtersHorizontally plus index shards
Embedding replicasBatch embedding for queries and ingestGPUs, separate from chat pools
GPU autoscalerAdd or remove replicas on queue and KV signalsControl loop

7. Detailed design

7.1 Request flow

One streaming chat request, from admission to metering. The quota reservation happens before queueing so a request that will exceed the tenant limit never occupies GPU memory.

7.2 Model servers and parallelism

  • Tensor parallelism splits each layer across the GPUs of one node; it needs fast GPU-to-GPU links, so a replica stays inside one node.
  • Pipeline parallelism splits layers across nodes; use it only for models that do not fit one node, because it adds latency per step.
  • Data parallelism is the replica count; it is what the autoscaler changes.
  • Example: the large pool runs 4-way tensor parallel per replica; the small model runs one replica per GPU.

7.3 Continuous batching, KV cache and paged attention

Static batching waits for every sequence in a batch to finish, so short answers wait for long ones and GPUs idle. Continuous (iteration-level) batching, described for the Orca serving system (Yu et al., OSDI 2022), adds and removes sequences at every decode step, so the batch stays full.

The KV cache stores keys and values of every past token so each new token attends to them without recomputation. Reserving contiguous memory for each sequence's maximum length wastes most of it. PagedAttention (Kwon et al., "Efficient Memory Management for Large Language Model Serving with PagedAttention", SOSP 2023) stores the KV cache in fixed-size blocks mapped through a per-sequence block table, like virtual memory pages. Blocks are allocated as a sequence grows, freed when it ends and can be shared between sequences with a common prefix.

Design consequences:

ConcernRule
Block sizeExample: 16 tokens per block, so the 427 000-token pool holds about 26 700 blocks
AdmissionAdmit a sequence only when its prompt's blocks are free
PreemptionWhen blocks run out mid-decode, preempt the lowest-priority, most recent sequence (swap to host memory or recompute later)
Prefix cachingShare blocks for identical system prompts; count cached tokens separately in metering
Context limitEnforce per-pool maximum context so one request cannot occupy the whole pool

7.4 Prefill versus decode

PropertyPrefillDecode
WorkAll prompt tokens in parallelOne token per sequence per step
Bound byComputeMemory bandwidth
SetsTTFTTPOT
InterferenceA long prefill pauses decode steps of the batchLarge batches raise TPOT slowly

Mitigations: split long prompts into chunks interleaved with decode steps (chunked prefill) so decode latency stays bounded; cap prompt tokens prefilled per step; for very long-context tenants consider a separate pool, or disaggregated prefill and decode replicas once the engine supports it.

7.5 Model routing and fallback

RuleConditionAction
RT-01 (Example)Alias assistant-large, interactiveLarge pool
RT-02 (Example)Prompt over 16 000 tokensLong-context pool
RT-03 (Example)Large pool queue wait p95 above 2 s, priority batchDefer batch until queue clears
RT-04 (Example)Large pool unhealthy, tenant opted in to fallbackSmall pool, response header X-Model-Fallback: true
RT-05 (Example)New model version in canary5% of traffic of opted-in tenants

Fallback to a different model changes answer quality, so it is opt-in per tenant and always visible in the response and in metering.

7.6 Autoscaling on GPUs

  • Scale on pending requests per replica and KV cache block usage, not GPU utilisation (which reads near 100% whenever any batch runs).
  • Example policy: add a replica when queue wait p95 exceeds 1 s for 2 minutes or block usage exceeds 90%; remove one when block usage stays below 40% for 15 minutes.
  • Cold start (node provisioning, image pull, weight load of 140 GB) can take minutes. Keep a minimum of 3 replicas, pre-pull weights to local disk and scale ahead of known peaks from the daily pattern.
  • GPU capacity may be unavailable when needed; reserve the minimum and the expected peak, and use spot capacity only for the batch class.

7.7 Quantization trade-offs

VariantWeight memory (70B)KV per tokenGPUs per replicaQuality risk
BF16 weights and KV140 GB320 KiB4Baseline
FP8 weights, BF16 KV70 GB320 KiB2 (KV pool about 66 GB)Low on most tasks; evaluate
FP8 weights and FP8 KV70 GB160 KiB2 (about twice the tokens of the row above)Low to medium; evaluate long context
INT4 weight-onlyabout 35 GB plus scales320 KiB1 to 2Medium; evaluate reasoning and code

For the FP8 row: 0.9×160−70−8=660.9 \times 160 - 70 - 8 = 66 GB of KV pool on 2 GPUs. Adopt a variant only after it passes the same evaluation suite as the baseline, per task, with results recorded in the model change ADR.

7.8 Multi-tenancy and rate limits

  • Quotas per tenant and model alias in tokens per minute and requests per minute; concurrency limit per tenant to stop one tenant filling the batch.
  • Priority classes map to queue weights: interactive first, standard next, batch only on spare capacity. Batch requests carry long deadlines and are preempted first.
  • Isolation of data: no cross-tenant prefix sharing unless the prefix is a platform-provided system prompt; vector collections are per tenant with access checked on every query.
  • Load shedding and deadline rules follow the Resilience and Load Shedding Design Template (architecture/resilience-load-shedding-design).

7.9 Vector index

IndexHow it worksStrengthsWeaknesses
Flat (exact)Compare the query with every vectorExact recallLinear cost; small collections only
HNSWLayered proximity graph searched greedily (Malkov and Yashunin)High recall at low latency; incremental insertsMemory for graph links; slow rebuilds
IVFCluster vectors; search only the nearest nprobe clustersLower memory; fast buildRecall depends on nprobe and cluster balance
IVF-PQIVF plus product-quantized codesVery small memoryLower recall; needs re-ranking with full vectors

Recall versus latency is tuned per collection: for HNSW raise ef_search until recall at 10 reaches the target on a labelled query set, then measure p99 latency; for IVF raise nprobe. Filters applied after search can return fewer than k results, so use the engine's filtered search or over-fetch.

7.10 Embedding pipeline

  • Ingest events enter a queue; embedding workers batch texts by length to fill GPU batches; results are upserted with document ID and version.
  • Each collection pins one embedding model version. Changing the model means re-embedding into a new collection and switching an alias, never mixing vectors from two models in one index.
  • Query embedding runs on a separate low-latency pool so ingest backlogs do not slow search.

8. Scalability and performance

ConcernApproachLimit before redesign
Interactive latency under mixed loadPriority queues, chunked prefill, per-tenant concurrency capsKV pool exhaustion at about 244 average sequences per replica
Long promptsLong-context pool, context capsPool size
Burst from one tenantToken rate limits and concurrency capsGateway counter store throughput
Vector searchShard by collection, replicas for read throughputLargest single collection in one shard's memory
Cold startMinimum replicas, pre-pulled weightsGPU availability in region

Latency budget for interactive TTFT (target p95 1.0 s, 1 500-token prompt):

StepBudget
Gateway auth, quota, routing20 ms
Queue wait500 ms
Prefill (3.4)130 ms
First decode step and streaming50 ms
Headroom300 ms

9. Reliability, security and operations

9.1 Failure modes

IDFailureImpactDetectionMitigation
FM-01GPU or node failureStreams on that replica cutReplica health, stream errorsRouter stops sending; client retry with idempotent request ID; N+1 capacity
FM-02KV pool exhaustionPreemptions, TTFT spikeBlock usage, preemption countAutoscale; lower batch cap; shed batch class
FM-03Bad model versionQuality regressionCanary evaluation, user feedbackVersion pinning; rollback alias
FM-04Weight store unavailableCannot scale upPull errorsNode-local cache; regional replica of weights
FM-05Index shard downSearch fails for a collectionShard healthReplicas per shard; degrade to keyword search where the application supports it
[FM-nn][Failure][Impact][Signal][Mitigation]

9.2 Security

IDThreatControl
SEC-01Tenant reads another tenant's vectorsCollection ACL checked on every query; tenant ID in every index key
SEC-02Prompt and output leakage through logsLogging off by default; redaction; retention limits
SEC-03Cache side channel through shared prefixesPrefix sharing only within a tenant or for platform prompts
SEC-04Model supply chain (tampered weights)Signed artifacts, checksum on load, provenance record
SEC-05Denial of wallet (huge max_tokens floods)Token reservation at admission; per-tenant caps
[SEC-nn][Threat][Control]

Application-level risks such as prompt injection belong to each tenant's threat model; see Threat Model Template (security/threat-model).

9.3 Observability

Instrument with the conventions in LLM and Agent Observability Specification Template (ai-data/llm-observability-spec).

SignalMetricAlert threshold
TTFTp95 by pool and priorityAbove 1.0 s for 10 min (interactive)
TPOTp95 by poolAbove 50 ms for 10 min
Queue waitp95 by pool and priorityAbove 2 s
KV block usagePer replicaAbove 95% for 5 min
PreemptionsPer minute per replicaDoubling vs. baseline
Tokens per secondPrompt and output per poolCapacity dashboard
Recall at 10Weekly evaluation per collectionBelow 0.95

9.4 Cost estimate

ItemUnit costQuantityMonthly cost
Large pool GPUsUSD 2.50 per GPU-hour (Example)[Average GPUs x 730 h][USD]
Small pool and embedding GPUs[USD per GPU-hour][GPU-hours][USD]
Vector index nodes[USD per node-month][Nodes][USD]
Gateway, router, storage[USD per month][Units][USD]
Total[USD]

Track cost with Cloud Cost Review Template (FinOps) (ops/finops-cost-review).

10. Trade-offs and alternatives

DecisionOptionsChosenWhyWhat we give up
Fleet modelPer-team GPUs; shared poolsShared pools with quotasUtilisation and one place for limitsNoisy-neighbour risk to manage
HostingExternal model API; self-hostedSelf-hosted for these models, passthrough for othersData control and cost at volumeOperations burden and GPU procurement
BatchingStatic; continuousContinuous with paged KV cacheThroughput and memory efficiencyEngine dependency
PrecisionBF16; FP8; INT4BF16 at launch, FP8 after evaluationQuality first, cost laterTwice the GPUs per replica until FP8
Scaling signalGPU utilisation; queue and KV usageQueue and KV usageReflects latency riskEngine-specific metrics
Vector indexFlat; HNSW; IVF-PQHNSW with int8, IVF-PQ for archiveRecall and latency for hot data; memory for coldTwo index types to operate
[Decision][Options][Chosen][Why][Cost]

11. Delivery plan and risks

11.1 Milestones

MilestoneScopeExit criterionTarget date
M1Gateway, quotas, small model poolTwo tenants migrated; usage metering reconciledYYYY-MM-DD
M2Large model pool with autoscalingLoad test at 1.5 times forecast meets NFR-01 and NFR-02YYYY-MM-DD
M3Retrieval service and HNSW collectionsRecall and latency per NFR-05 on each migrated collectionYYYY-MM-DD
M4Priority classes and batch inferenceMixed-load test meets NFR-04YYYY-MM-DD
M5FP8 variantEvaluation parity per task; ADR approvedYYYY-MM-DD

11.2 Rollout and rollback

[Example: Tenants move one at a time behind the same API; the old server stays available for 30 days. Model versions roll out by alias with a 5% canary and automatic rollback when the canary's evaluation score or error rate breaches its threshold.]

11.3 Risks

IDRiskLikelihoodImpactMitigationOwner
R-01Example: GPU capacity not available at peakMediumHighReservations for minimum plus peak; second region[@name]
R-02Example: Measured throughput below estimateMediumMediumBenchmark before purchase; FP8 path[@name]
R-03Example: Model licence restricts use or scaleLowHighLicence review per model version[@name]
R-04Example: Tenants depend on fallback silentlyMediumMediumOpt-in, header and dashboard[@name]
[R-nn][Risk][L / M / H][L / M / H][Mitigation][@name]

12. Appendices

12.1 Traceability

RequirementDesign elementVerification
NFR-017.3 admission, 7.4 chunked prefill, 7.8 prioritiesLoad test with prompt length mix
NFR-023.4 decode sizing, batch capLoad test inter-token intervals
NFR-047.8 priority queues and concurrency capsMixed-tenant test
NFR-057.9 index tuningRecall test set per collection
NFR-063.6 cost model, meteringMonthly chargeback
[ID][Element][Test]

12.2 Open questions

IDQuestionOwnerDue
OQ-01Example: Do we offer a dedicated pool for regulated tenants?[@name]YYYY-MM-DD
OQ-02Example: Is disaggregated prefill worth it at our prompt lengths?[@name]YYYY-MM-DD
[OQ-nn][Question][@name]YYYY-MM-DD

12.3 Glossary

TermMeaning
PrefillProcessing all prompt tokens to build the KV cache before the first output token
DecodeGenerating output tokens one step at a time
KV cacheStored attention keys and values for past tokens
TTFTTime to first token, from request receipt to first streamed token
TPOTTime per output token, the mean interval between streamed tokens
Continuous batchingAdding and removing sequences from the running batch at each step
Recall at kShare of the true k nearest neighbours that the index returns
HNSWHierarchical Navigable Small World graph index
IVFInverted file index over vector clusters

12.4 References

ReferenceUse
Kwon et al., "Efficient Memory Management for Large Language Model Serving with PagedAttention", SOSP 2023 (arXiv:2309.06180)Paged KV cache in 7.3
Yu et al., "Orca: A Distributed Serving System for Transformer-Based Generative Models", OSDI 2022Iteration-level batching in 7.3
Ainslie et al., "GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints", EMNLP 2023 (arXiv:2305.13245)KV heads in 3.3
Malkov and Yashunin, "Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs" (arXiv:1603.09320)HNSW in 7.9
RAG System Design Template (ai-data/rag-system-design)Application layer on this platform
Capacity Plan Template (ops/capacity-plan)GPU capacity planning
[Inference engine and hardware documentation]Engine settings and measured rates

Standard and licence note

Based on common industry practice for LLM serving and vector search and on the published research in 12.4. Hardware and throughput figures are illustrative examples, not benchmarks; measure on your own engine, model and hardware, and check the current documentation of each component. Original text written for this collection. Template licence: MIT.

相关模板