Q&A-2Choose among real-time, asynchronous, batch, and streaming inference.
Answer
What I'd say first
Assume a fraud model on card authorizations: 2,000 req/s peak, a 100 ms p99 budget, features from a 5-minute sliding window, and a nightly retrain. The mode is decided by two questions: does the caller block on the answer, and how stale may the inputs be?
- Real-time (synchronous) when the caller blocks: auth, ranking, ad selection. The budget is end-to-end p99, not GPU kernel time.
- Asynchronous when the caller can wait seconds to minutes and needs a durable handle: LLM generation, document scoring, video. Return a job id, deliver by webhook or poll.
- Batch when the input set is bounded and the schedule's staleness is acceptable: nightly scores for 40M users written to the feature store.
- Streaming when each event must be scored as it arrives and the decision depends on state across events: velocity checks, session features, windowed aggregates.
Deciding criteria
| Criterion | Real-time | Async | Batch | Streaming |
|---|---|---|---|---|
| Freshness | ms | s–min | up to schedule interval | ms–s |
| Caller blocks? | yes | no | no | no |
| State across events | no | no | no | yes (keyed state, watermarks) |
| Cost per prediction | highest (peak-provisioned) | medium | lowest | medium |
| Retry semantics | caller retries, must be idempotent | at-least-once + idempotency key | whole-job rerun | exactly-once via checkpoints |
Worked sizing (hypothetical)
One A10G runs the model at 6 ms batch-1 and 30 ms at batch 32, so ~1,000 req/s per GPU. Triton with max_batch_size=32 and max_queue_delay_microseconds=5000. At 2,000 req/s peak you need 2 GPUs; at 50% utilization p99 ≈ 2 ms network + 5 ms queue + 3 ms preprocess + ~1 ms GPU + 2 ms postprocess ≈ 13 ms, well inside 100 ms.
Now the spike: 5,000 req/s needs 5 GPUs. With 2, the GPU is 2.5× oversubscribed, so the queue grows without bound: max_queue_delay_microseconds caps how long a request waits before batching, not the backlog behind it. p99 goes from 13 ms to seconds in roughly 10 s. Autoscaling on GPU utilization can't save you: a 15 s metric scrape plus 60–90 s node provisioning. You need admission control or load shedding at the edge, and a fallback rule-based decision.
Failure modes and detection
- Real-time: pool saturation. Detect on Triton's
nv_inference_queue_duration_usand deadline-miss rate, not GPU utilization: utilization sits at 100% long before p99 breaks. - Async: a poison message retried forever, duplicate side effects. Detect on DLQ depth and retry count; require an idempotency key on the job.
- Batch: silent staleness. The 02:00 job fails, nobody notices, the store serves yesterday's scores. Detect with a freshness SLA: alert when
now - max(event_time)exceeds 2× the schedule interval. - Streaming: backpressure. Consumer lag grows when input rate exceeds processing rate; detect on Kafka consumer lag and Flink checkpoint duration. State that grows unboundedly lengthens checkpoints and restarts; late events past the watermark are dropped, so decide drop-vs-update explicitly.
When a mode is wrong
Don't use real-time for anything a human doesn't block on: you pay peak-provisioning cost for idle GPUs. Don't use batch when the decision needs the last 5 minutes. Don't use streaming when the input is a bounded file; you inherit state, watermarks and checkpointing for nothing. Hybrid is normal, streaming features feeding a real-time model, but every path must serve the same versioned prediction contract, or the modes disagree on the same input.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.