When would you serve predictions in batch vs online? What hybrid patterns exist?
Answer
Model answer, written in a candidate's voice
In short
- Batch when entities are known in advance and staleness is acceptable; cheap and simple to run, e.g. daily scores and email targeting.
- Online for fresh context and latency SLAs, e.g. payments and search, with more ops burden.
- Hybrid: precompute embeddings or candidates in batch, re-rank online, cache results.
- Publish batch predictions as events consumed by other systems, keeping downstream services decoupled from the model pipeline.
In full
I’d use batch when the entities to score are known in advance, the decision can tolerate staleness, and the output is consumed downstream rather than in the request path—daily scores, email targeting, or similar — because it is cheap and simple to run. I’d use online when fresh context matters and there is a latency SLA, such as payments or search, accepting the extra serving, monitoring and failure-handling burden. In practice I like hybrids: precompute embeddings, candidate sets or features in batch, then re-rank or score online with a tight timeout, and cache results where the same input repeats. A useful pattern is to publish batch predictions as events that other systems consume, so downstream services stay decoupled from the model pipeline. The choice is less about the model than about freshness, latency, cost and who consumes the output.
What a strong answer covers
- Batch: cheap, simple, can be stale; suits daily scores and email targeting.
- Online: fresh context, latency SLAs, more ops burden; needed for payments and search.
- Hybrid: precompute embeddings or candidates in batch, re-rank online; cache results.
- Batch predictions can be published as events that other systems consume.
Common mistakes
- choosing real-time by default
- ignoring feature freshness requirements.