Batch versus real-time architecture
Quick answer
Batch serving computes scores ahead of use, while online serving computes a response when a request arrives. Choose the path from decision deadlines, feature freshness and failure behavior, not from the prestige of real-time systems. Examples use small inert synthetic inputs and standard-library Python. No real endpoints. ByteMind execution is unverified.
Check freshness at decision time
decision=120records=[(85,90),(105,125),(110,115)]print([event for event,available in records if available<=decision and 0<=decision-event<=20])Expected output (locally tested): [110]. Only a recent record already available at decision time qualifies.
How it works
A nightly maintenance schedule can read a versioned batch snapshot; a current equipment event may need a bounded synchronous response. Batch cost includes job compute and result storage; online cost includes idle capacity and peaks. Define end-to-end freshness as decision time minus feature event time, with availability time checked separately. Use the same preprocessing contract and model version for both paths, test parity on matching inputs, and record prediction time and source versions. A batch job should be idempotent, with atomic publication after validation. An online request must have a deadline, bounded retries and a safe fallback such as manual review. A stale batch score is not automatically a safe online fallback. Streaming ingestion is distinct from synchronous inference.
Compare batch and online score parity
def score(x): return 2*x+1rows=[2,4,6]batch=list(map(score,rows))online=[score(x) for x in rows]print(batch, batch==online)Expected output (locally tested): [5, 9, 13] True. A shared deterministic transformation matches on identical values.
Common mistakes
Do not compare batch throughput to online latency without units. Do not substitute a stale score when the contract forbids it, or retry without a deadline. Parity on identical inputs does not prove identical production feature availability.
Practice and next steps
Given an hourly planning job and an urgent equipment alert, choose a path for each and define its freshness and response deadline. Next specify who approves the model.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Batch versus real-time architecture — knowledge check
Apply batch versus real-time architecture to small examples and debugging scenarios.
Which workload best suits nightly batch scores?
What is feature freshness here?
What prevents partial batch publication?
When may a fallback score be used?
What does matching score parity show?