What you will be able to do
- Tell batch, streaming and real-time inference apart by what triggers scoring, what gets scored, and who waits for the result
- Pick the serving approach that fits a scenario's latency, throughput and cost requirements, and explain why the other approaches fit worse
- Recognise when precomputed batch predictions published to a key-value store can meet a low-latency requirement without a real-time endpoint
Key concept
Serving approach — How a trained model's predictions reach their consumer. Batch scores a whole table on a schedule, streaming scores only the new rows as they arrive, and real-time answers one request at a time behind a REST API. The approaches trade latency against cost and throughput.
1.Three ways a model's predictions reach their consumer
A registered model is only useful once its predictions reach something that acts on them. Databricks offers three ways to get them there, and the real difference between them is who is waiting for the answer. In batch inference, a scheduled job scores a whole table and writes the results, and nobody waits on any single row. In streaming inference, a pipeline that is always running (or triggered often) scores each new record as it lands and appends the result. In real-time inference, a caller such as a checkout service or web app sends one request and blocks until the model replies.
The three are separate options on the platform, not one product tuned three ways. Databricks lists batch serving and low-latency online serving as distinct deployment options. Model Serving is the real-time option: each model you serve becomes a REST endpoint that an application calls directly. Batch and streaming jobs run as ordinary data pipelines. They load the registered model and write predictions to storage, and consumers read the predictions from there.
Cost and latency move in opposite directions across the three. Batch and streaming score many rows per unit of compute, so they are cheap per prediction, but a prediction appears minutes or hours after its input. A real-time endpoint answers in milliseconds, but it has to be provisioned and kept ready for requests that might arrive at any moment. For any workload, the first question is how soon after the input each prediction must exist, and whether a person or system is blocked waiting for it.
Checkpoint 1 of 8· Match them up
Match each workload to the serving approach that fits it best
Tap a term, then the definition that fits it.
The deciding question is who waits for the answer. A caller blocked on one decision needs a REST endpoint from Model Serving. When nobody waits on a single row, a scheduled batch job or an incremental streaming pipeline can write predictions to storage more cheaply.
“For real-time use cases, you must set up the infrastructure to deploy the model as a REST API endpoint.”Source: docs.databricks.com
2.Batch inference: score the whole table on a schedule
Batch inference reads every row currently in the source and scores all of them in one run. The engine does not track what it has already processed, so each run reprocesses the data and overwrites the previous results. That makes the logic simple and the output complete: every run reflects all the data available at that moment. Batch sources are usually partitioned, for example by day or region, so a run can be limited to a slice of the data instead of reprocessing everything.
The cost of this simplicity is latency. Batch can meet requirements measured in hours or minutes, but not seconds or milliseconds. For many ML workloads that is fine. Take a churn model scored against the full customer table every night, with results read by a dashboard the next morning. No prediction is needed within seconds of a customer event, so a nightly job is the cheapest and simplest design that meets the requirement. A real-time endpoint for that workload would keep serving infrastructure running for a job whose consumer reads results once a day. A streaming pipeline would keep running to watch a source that does not change overnight.
The batch job itself is ordinary Python or Spark code. It loads the registered model, often by its champion alias so that a newly promoted version is picked up on the next run, then scores the data and writes the predictions out. For Python models, mlflow.pyfunc.load_model() returns the model as a generic Python function with a predict method. The same model can also be exported as a Spark UDF so that scoring is spread across a cluster. Both techniques are covered in batch inference with pandas. Batch jobs usually write their predictions to tables in the production catalog, to flat files, or over a JDBC connection.
Checkpoint 2 of 8· Check yourself
A nightly batch job scores the full customer table with the champion churn model. Some of yesterday's customer records reach the source table only after last night's run has finished. What happens to those records on tonight's run?
Batch does not track what it has already processed. Each run scores all the data currently in the source and overwrites the previous results, so late records are picked up and the output is complete. Scoring only the new rows and appending the results is what streaming does.
“With batch, data from previous hours is reprocessed each hour, and the previously calculated results are overwritten to reflect the latest results.”Source: docs.databricks.com
Checkpoint 3 of 8· Exam question
A retail analytics team scores a churn model against the full customer table once every night and writes the predictions to a Delta table that a dashboard reads the next morning. No individual prediction needs to be available within seconds of a new customer event. Which serving approach best fits this workload, and why?
Correct answer: A — Batch inference, because loading the model with mlflow.pyfunc.load_model and applying it across the full table on a schedule is cheaper and simpler when low millisecond latency is not required.
- A. Nightly scoring of a full table with no sub-second latency requirement is the canonical batch inference pattern: loading the model once and applying it across the dataset (for example via a pandas UDF or
.apply) avoids the operational overhead of a standing endpoint. - B. A REST endpoint is built for low-latency request/response traffic; polling it for a nightly bulk job adds endpoint management and per-request overhead that a scheduled batch job does not need.
- C. Streaming inference is designed for continuously arriving records from a source like Auto Loader or a message queue; running it against a table that only changes once a day processes no new data most of the time and wastes the always-on compute.
- D. Scale-to-zero reduces idle cost but the endpoint still has to warm up and serve individual requests one at a time, which is a worse fit for scoring an entire table than a single scheduled batch pass.
3.Streaming inference: score only what is new, as it arrives
Streaming inference keeps track of what it has already processed and scores only data that arrived since the last run. New results are appended to earlier ones instead of overwriting them. That makes streaming more efficient than batch, because no row is scored twice. It also makes streaming faster: it can meet latency requirements anywhere from hours down to seconds and milliseconds. On Databricks, Structured Streaming is the underlying engine. It treats cloud object storage and Delta tables as streaming sources, and Auto Loader picks up new files as they land in cloud storage.
The efficiency costs accuracy. When late records arrive, a batch job processes them together with the rest of their hour and overwrites the old result, so the output comes out correct. A streaming job sees only the late rows. It must have kept the state of earlier calculations, such as running sums and counts, to correct the result. Stateful work like joins, aggregations and deduplication makes streaming logic complex, and its results cannot always be accurate when data arrives late or out of order. Simply scoring each new row with a model is stateless, which is why per-record inference is a good fit for streaming.
In practice, streaming inference means the model becomes one step inside a pipeline. Consider IoT sensor readings ingested continuously through Auto Loader into Lakeflow Spark Declarative Pipelines (formerly Delta Live Tables). Each reading needs an anomaly score, but no person or downstream system is waiting on any single call. Applying the model as a transformation inside the pipeline scores each reading as it flows through, and no separate scheduled job is needed. A recurring batch job would fall behind the data between runs. Calling a REST endpoint for every row would make the pipeline block on network round-trips it has no need to wait for. Spark pandas UDFs scale both batch and streaming inference across a cluster. The mechanics of the pipeline are covered in streaming inference with declarative pipelines. Streaming jobs usually write predictions to Unity Catalog tables or to message queues such as Apache Kafka.
Structured Streaming has two trigger types. Micro-batch mode, the default, processes new data in small batches and suits latencies measured in seconds or minutes. Real-time mode (RTM) processes records as they arrive and is aimed at sub-second operational work such as fraud detection, but it needs dedicated compute. Even in RTM, the output still goes to a sink, the destination a pipeline writes to, such as a table or a Kafka topic, so a caller would have to read its result from there afterwards. A streaming pipeline produces a stream of results, not a reply to a caller.
Checkpoint 4 of 8· Check yourself
Your team wants to retire the Model Serving endpoint that the checkout service calls for fraud scores. The checkout service holds the payment screen until it gets a score. The proposed replacement is a Structured Streaming pipeline in real-time mode (RTM). What should you recommend?
Even in real-time mode, a streaming pipeline sends a stream of results to a sink. It does not answer a caller. A service that blocks waiting for each decision needs the model deployed as a REST API endpoint through Model Serving.
“For real-time use cases, you must set up the infrastructure to deploy the model as a REST API endpoint.”Source: docs.databricks.com
Checkpoint 5 of 8· Exam question
A sensor-monitoring pipeline built on Lakeflow Spark Declarative Pipelines ingests IoT readings continuously via Auto Loader and needs to attach an anomaly score to each reading as it flows through the pipeline, without a person or downstream system waiting on any single call. Which serving approach fits this scenario, and what makes it a better fit than the alternatives?
Correct answer: A — Streaming inference, because applying a registered MLflow model as a transformation inside the declarative pipeline scores each new record as it arrives, with no separate scheduled job needed.
- A. Scoring records as they flow through an already-continuous pipeline by loading the model as a UDF inside the pipeline transformation is the streaming inference pattern, matching the continuous ingestion and avoiding a separate synchronous call per row.
- B. Scheduling batch scoring on top of a continuously arriving stream introduces artificial delay between when a reading lands and when it is scored, undoing the low-latency benefit that a continuously running pipeline already provides.
- C. Calling a REST endpoint synchronously for every row inside a high-throughput streaming pipeline adds network round-trip overhead per record and turns the pipeline's throughput into a function of endpoint request latency.
- D. Splitting continuously arriving sensor data between a batch path and a real-time path adds two serving mechanisms to maintain for one continuous data source when the pipeline can score every record inline as it passes through.
4.Real-time serving: answer each request behind a REST API
Real-time inference is for a caller that sends one input and waits for one prediction. Model Serving exposes each served model as a REST API with high availability and low latency. It runs on serverless compute that automatically scales up or down as demand changes, so you save infrastructure cost when traffic drops and keep latency low when traffic spikes. Unlike batch or streaming, which can simply load the champion model inside a pipeline, a real-time use case needs dedicated infrastructure that deploys the model as a REST endpoint.
A fraud model that must approve or decline a card swipe within 100 milliseconds, with request volume that rises and falls sharply over the day, is the standard example. The checkout service needs an answer about this particular transaction, so a nightly job that pre-scores yesterday's transactions cannot help: the swipe has not happened yet. A streaming table writes its score to a Delta table, and the checkout service would then have to find that row and read it back. A fixed-size cluster that is always on costs money at 3 a.m. and can still run out of capacity at noon. An autoscaling REST endpoint meets both the latency requirement and the varying load.
Endpoints also handle feature lookup and model updates themselves. Feature tables are Unity Catalog tables that hold the input features a model is trained on, such as a customer's purchases over the last 30 days. If the served model version was trained on them, the model stores which features and functions it depends on, and Model Serving uses those stored dependencies to look the feature values up from online stores, which are low-latency stores meant for lookups at request time. When a new version replaces the old one, the existing configuration keeps serving requests until the new one is ready, so the update causes no downtime. Creating and querying an endpoint is covered in real-time deployment and querying, and splitting traffic between models on one endpoint is covered in splitting traffic between endpoints.
Checkpoint 6 of 8· Check yourself
Investigators at a card issuer want every transaction that arrives on a Kafka topic scored for fraud within a second. Flagged transactions should be written to a Delta table that they review. No checkout service or other caller waits for the score. Which design fits?
Look at the consumer. Nothing blocks waiting on a reply: a pipeline flags records continuously and writes them downstream. That makes this a streaming workload, and real-time mode meets the sub-second requirement. Calling an endpoint for each row would make the pipeline wait on network round-trips for no reason. Micro-batch and hourly batch are both too slow for sub-second latency.
“Use RTM for operational workloads that require immediate response to streaming data, such as fraud detection and real-time personalization.”Source: docs.databricks.com
Checkpoint 7 of 8· Exam question
A fraud-detection model must return an approve/decline decision to a checkout service within 100 milliseconds of a card being swiped, and the volume of requests varies sharply between business hours and overnight. Which approach satisfies both the latency and the variable-load requirement?
Correct answer: A — A Databricks Model Serving REST endpoint, because it exposes the model over a low-latency API and automatically scales compute up or down as request volume changes.
- A. Model Serving endpoints are purpose-built for synchronous, low-latency request/response traffic and scale automatically with demand, which matches both the 100ms requirement and the swings between business hours and overnight.
- B. Batch scoring the previous day's transactions produces decisions for events that already happened, which cannot support a checkout flow that needs a decision at the moment of the swipe.
- C. A streaming pipeline writing to a Delta table adds the latency of a micro-batch or continuous trigger and a table read before the checkout service sees a result, which is not a synchronous request/response path suited to a 100ms budget.
- D. A fixed-size always-on cluster avoids cold starts but does not scale down during overnight lulls or scale up during peak hours, so it either overpays for idle capacity or falls behind under load.
5.Choosing an approach, and when precomputed predictions are enough
| Aspect | Batch | Streaming | Real-time |
|---|---|---|---|
| What triggers scoring | A schedule; all rows in the source or partition | New data arriving; only rows not yet processed | An individual request from a client |
| Typical latency | Hours to minutes | Minutes down to seconds or milliseconds | Low latency, the caller waits for the reply |
| Cost profile | Most cost-effective for high throughput | Cost-effective for high throughput; efficient because only new data is processed | Dedicated REST endpoint infrastructure, autoscaled with demand |
| Where predictions go | Production catalog tables, flat files, JDBC | Unity Catalog tables or message queues like Apache Kafka | Returned in the REST API response |
Most scenarios can be decided with the table. The one that catches people out is a low-latency requirement for a prediction that does not depend on anything happening at request time.
Needing a prediction with low latency is different from needing to compute it with low latency. If every input is known in advance, as with a score per customer, per product or per account, a batch job can compute all the predictions offline and publish them to an online key-value store such as DynamoDB or Cosmos DB. The application then looks up a stored value, which is fast, and you pay batch prices for the scoring. This only works if the prediction can be computed before the request arrives. A swipe at checkout, a search query typed a moment ago, or anything else that depends on data available only at request time still needs a real-time endpoint.
Score every customer in a weekly batch job and publish the rankings to an online key-value store for the page to look up. That meets the 200 ms requirement at batch cost. Switch to a real-time endpoint if the ranking must use something only known at request time, such as the item currently in the cart.
Checkpoint 8 of 8· Check yourself
Four product teams each need a prediction shown within milliseconds. Which of them still needs a real-time Model Serving endpoint, rather than a batch job that publishes to an online key-value store?
Batch scoring plus a key-value lookup works only when every prediction can be computed before the request arrives. A ranking that depends on a query typed a moment ago uses data that exists only at request time, so it needs a real-time endpoint. The other three are per-product, per-account or per-customer scores that can be computed ahead of time.
“low-latency predictions are required, but predictions can be computed offline, these batch predictions can be published to an online key-value store”Source: docs.databricks.com
Sources
(7)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“Each model you serve is available as a REST API that you can integrate into your web or client application.”
↩︎ Three ways a model's predictions reach their consumer“The service automatically scales up or down to meet demand changes, saving infrastructure costs while optimizing latency performance.”
↩︎ Real-time serving: answer each request behind a REST API“Model Serving provides a highly available and low-latency service for deploying models.”
↩︎ Real-time serving: answer each request behind a REST API - 2.
“Batch or streaming inference is generally the most cost-effective option for higher throughput, higher latency use cases.”
↩︎ Three ways a model's predictions reach their consumer“Batch jobs typically publish predictions to tables in the production catalog, to flat files, or over a JDBC connection.”
↩︎ Batch inference: score the whole table on a schedule“Streaming jobs typically publish predictions either to Unity Catalog tables or to message queues like Apache Kafka.”
↩︎ Streaming inference: score only what is new, as it arrives“Model Serving automatically uses this dependency graph to look up features from appropriate online stores at inference time.”
↩︎ Real-time serving: answer each request behind a REST API“the model stores the dependencies for the features and functions.”
↩︎ Real-time serving: answer each request behind a REST API“Model Serving executes a zero-downtime update by keeping the existing configuration running until the new one is ready.”
↩︎ Real-time serving: answer each request behind a REST API“these batch predictions can be published to an online key-value store such as DynamoDB or Cosmos DB”
↩︎ Choosing an approach, and when precomputed predictions are enough“Batch or streaming inference is generally the most cost-effective option for higher throughput, higher latency use cases.”
↩︎ Key concept“For real-time use cases, you must set up the infrastructure to deploy the model as a REST API endpoint.”
↩︎ Exam trap 2“these batch predictions can be published to an online key-value store such as DynamoDB or Cosmos DB”
↩︎ Exam trap 3“For real-time use cases, you must set up the infrastructure to deploy the model as a REST API endpoint.”
↩︎ Checkpoint“For real-time use cases, you must set up the infrastructure to deploy the model as a REST API endpoint.”
↩︎ Checkpoint“low-latency predictions are required, but predictions can be computed offline, these batch predictions can be published to an online key-value store”
↩︎ Checkpoint - 3.
“Batch and streaming scoring supports high-throughput, low-cost scoring at latencies as low as minutes.”
↩︎ Three ways a model's predictions reach their consumer“Use Spark Pandas UDFs to scale batch and streaming inference across a cluster.”
↩︎ Streaming inference: score only what is new, as it arrives - 4.
“With batch processing, the engine does not keep track of what data is already being processed in the source.”
↩︎ Batch inference: score the whole table on a schedule“Slower, could handle latency requirements from hours to minutes, but not seconds or milliseconds.”
↩︎ Batch inference: score the whole table on a schedule“With streaming processing, the engine keeps track of what data is being processed and only processes new data in subsequent runs.”
↩︎ Streaming inference: score only what is new, as it arrives“Processing logic could be complex, especially for stateful processing such as joins, aggregations, deduplications, etc.”
↩︎ Streaming inference: score only what is new, as it arrives“Faster, could handle latency requirements from hours to minutes, seconds, and milliseconds.”
↩︎ Choosing an approach, and when precomputed predictions are enough“Results cannot always be accurate, considering out-of-order and late-arrival data.”
↩︎ Exam trap 1“With batch, data from previous hours is reprocessed each hour, and the previously calculated results are overwritten to reflect the latest results.”
↩︎ Checkpoint - 5.https://docs.databricks.com/aws/en/mlflow/modelsOfficial docs
“For Python MLflow models, an additional option is to use mlflow.pyfunc.load_model() to load the model as a generic Python function.”
↩︎ Batch inference: score the whole table on a schedule - 6.
“Auto Loader Incrementally and efficiently process new data files as they arrive in cloud storage.”
↩︎ Streaming inference: score only what is new, as it arrives - 7.
“Real-time mode (RTM) is a trigger type for Structured Streaming that is up to 100x faster than micro-batch mode.”
↩︎ Streaming inference: score only what is new, as it arrives“Use RTM for operational workloads that require immediate response to streaming data, such as fraud detection and real-time personalization.”
↩︎ Real-time serving: answer each request behind a REST API