Library

Volume 1 · Additional Advanced System Design Scenarios

Notebook
Sign in

Cheat Sheet — Part 12: Additional Advanced System Design Scenarios

872 words · about 4 min

Key Terms

Term In one line
Zipfian traffic Heavily skewed — a few tenants generate most load; drives every caching decision
Adapter hot-swap Shared base model in GPU memory, per-tenant LoRA adapters loaded on demand
Three-tier adapter cache Hot in GPU memory · warm in host RAM · cold in blob storage
Delayed labels Ground truth arrives weeks later (chargebacks) — breaks naive retraining
Class imbalance Fraud at 0.1–0.5% — accuracy is a meaningless metric here
Feature store Consistent features for training and serving; online store is on the latency path
Rolling aggregate Streaming-maintained window features (“transactions on this card in 10 min”)

Numbers That Matter — Multi-Tenant Fine-Tuned SaaS

Figure Value
Tenants 400; 90% LoRA (rank 16–64, ~20–200 MB each), 10% full fine-tune
Load 5,000 QPS peak, Zipfian — top 20 tenants ≈ 3,500 QPS (70%), next 80 ≈ 1,250 (25%), remaining 300 ≈ 250 combined
Latency target p99 800 ms time-to-first-token, 40 ms/token streaming (7B–13B base)
GPU sizing One A100-80GB: base ~16 GB fp16 + KV cache + 30–50 resident adapters (~5 GB)
Adapter storage 360 LoRA × ~100 MB = 36 GB; 40 full fine-tunes × 14 GB = 560 GB (7B fp16)
Warm cache ~400 adapters × 150 MB = 60 GB host RAM per cache host
Cold-start penalty 50–150 ms to load an adapter from blob — acceptable at <1 QPS/tenant
Base model tiers 2–3 fixed bases (e.g. 8B standard, 70B premium); tenants don’t bring arbitrary bases

Numbers That Matter — Real-Time Fraud Detection

Figure Value
Hard SLA p99 ≤100 ms end to end — it sits synchronously in checkout
Budget split Gateway/network 10–15 ms · rules 2–5 ms · feature assembly 10–20 ms · ML scoring <5 ms
Throughput 20,000 TPS peak
Fraud base rate 0.1–0.5% — extreme imbalance
False positive target <0.5% of legitimate transactions challenged
Label lag 30–90 days (chargebacks, disputes, network reports)

Decision Rules

  • Share the base, swap the adapter. The multi-GB base weights load once per GPU node and are shared read-only; per-tenant LoRA adapters are the only thing that moves. This is what turns per-tenant dedicated GPU economics into shared-infra economics.
  • Cache adapters in three tiers sized to the traffic skew: keep the top ~20 tenants’ adapters permanently resident in GPU memory, warm the rest in host RAM, and accept a 50–150 ms cold load from blob for the long tail — where it’s an infrequent tax, not a steady-state cost.
  • Don’t let tenants bring arbitrary base models. Offer 2–3 fixed tiers. Arbitrary bases destroy the sharing that makes the whole economic argument work.
  • Answer “why not just give the top 20 dedicated capacity?” — because you’d then operate two systems, you’d have no headroom to absorb a tenant becoming hot, and the long tail still needs the shared path anyway. The shared design already gives the top tenants resident adapters.
  • Gradient-boosted trees over deep models for fraud: sub-5 ms inference, interpretable feature importances (which regulators and analysts require), and strong performance on tabular data. Reserve the latency budget for feature assembly, which actually dominates.
  • With 0.1–0.5% fraud, never report accuracy. Use precision/recall at a fixed alert volume, PR-AUC, and cost-weighted metrics — a model predicting “never fraud” is 99.7% accurate and worthless.
  • Design explicitly for the 30–90 day label lag: train on matured windows only, monitor proxy signals in the interim, and never conclude a new model is better from a fortnight of unlabeled traffic.

Say This Out Loud

“Four hundred tenants each with their own fine-tune sounds like four hundred GPUs, and that’s the trap. The design that works is a shared base model with per-tenant LoRA adapters: the expensive multi-gigabyte base weights load once per node and are shared read-only, and the only per-tenant artifact is a hundred-megabyte adapter. Then I size the caching to the traffic skew — it’s Zipfian, so the top twenty tenants generating seventy percent of traffic get their adapters permanently resident in GPU memory, the middle sits warm in host RAM, and the long tail of three hundred tenants at under one QPS each pays a fifty-to-a-hundred-fifty-millisecond cold load from blob storage. At that request rate it’s an occasional tax, not a steady-state cost.”

“For fraud detection I’d budget the hundred-millisecond p99 explicitly before choosing anything: ten to fifteen milliseconds for gateway and network, two to five for the deterministic rules, ten to twenty for feature assembly — which is dominated by the feature-store round trip and is the real bottleneck — and under five for the model itself. That budget is why I’d use a gradient-boosted tree rather than a deep model: sub-five-millisecond inference, and feature importances an analyst and a regulator can both interrogate.”

“The two things that shape the fraud system most aren’t latency, they’re statistical. Fraud is a tenth to half a percent of transactions, so accuracy is a meaningless metric — a model that says ‘never fraud’ scores ninety-nine point seven percent. I’d evaluate on precision and recall at a fixed alert volume the review team can actually handle. And labels arrive thirty to ninety days late through chargebacks, so retraining has to run on matured windows, and I can’t conclude anything about a new model from two weeks of unlabeled production traffic.”