Sub topic 7
What Model Serving provides
This chapter explains what Databricks Model Serving is, what it does for you, and where its limits are. The later chapters on creating, querying and updating endpoints build on this model.
It assumes you can do the following:
- Train and call a scikit-learn style model in Python.
- Work in a Databricks workspace and notebooks.
- Read a REST call with a JSON body.
- Explain what a catalog, schema and table are in Unity Catalog.
You do not need to have deployed a model before.
The problem Model Serving solves
A registered model is a set of files and metadata. It can predict only when some process loads it and receives input. A notebook can do that for you, but other systems cannot depend on a notebook. A web application, a mobile backend or a streaming job needs a stable network address that accepts input and returns predictions at any hour.
Running that yourself means taking on several jobs:
- Build a container image with the right Python packages.
- Run the container on machines you manage.
- Put a load balancer and TLS in front of it.
- Add authentication.
- Scale the number of replicas up and down with traffic.
- Collect logs and metrics.
- Replace the model without dropping requests.
Databricks Model Serving takes over these jobs. You give it a registered model version, and it gives you a managed HTTPS endpoint.
The core objects
Three terms appear throughout the rest of the tutorial.
| Term | Meaning |
|---|---|
| Serving endpoint | A named, managed REST service. Its URL ends in `/serving-endpoints/<name>/invocations`. |
| Served entity | One thing the endpoint runs, such as version 1 of `main.default.iris_classifier`. An endpoint holds one or more served entities. |
| Endpoint configuration | The declared state of the endpoint: which served entities it has, their compute settings, and how traffic is divided among them. |
The endpoint name is the address that clients use. The served entity is the model behind it. This separation is what lets you change the model later without changing the address your clients call.
What happens when you create an endpoint
You create an endpoint from a model registered in Unity Catalog. The registered model must have a signature, which earlier chapters covered. Databricks then does the following:
- It reads the model version's artifacts and the dependency list that MLflow recorded when you logged the model.
- It builds a container image that installs those dependencies and loads the model.
- It starts the container on serverless compute that Databricks manages.
- It exposes the container behind an HTTPS endpoint that checks authentication on each request.
The endpoint stays in a not-ready state until the build and startup finish. Building takes minutes, not seconds. That is why the SDK example in the creation chapter uses create_and_wait, which blocks until the endpoint is ready.
Because the container is built from the dependencies recorded at logging time, the environment that served the model matches the environment that logged it. A model logged without correct requirements is a common reason for a build failure. The troubleshooting chapter covers this.
What kinds of models you can serve
Model Serving is not limited to scikit-learn. One serving interface covers several kinds of workload:
- Custom models. Any model logged with MLflow, including scikit-learn, XGBoost, PyTorch, and custom
pyfuncmodels that wrap your own Python code. This tutorial uses this kind. - Foundation Model APIs. Hosted large language models that Databricks runs for you, offered either pay-per-token or with provisioned throughput.
- External models. An endpoint that forwards requests to a model hosted by another provider. You manage credentials and access in one place.
- Agents. Applications built from language models, tools and retrieval steps, deployed as endpoints.
All of these share the same REST pattern and the same authentication, permissions and monitoring. Only the request payload differs. The rest of this tutorial focuses on custom models, because they follow directly from the registration work in the previous chapters.
What the platform handles for you
Compute and scaling
The endpoint runs on serverless compute. You choose a workload size, which sets how much concurrency each endpoint can handle. You can also enable scale to zero, which shuts the compute down when the endpoint is idle. The trade-off is that the first request after an idle period waits for the compute to start. A later chapter covers this choice in detail.
Security and access control
Every request must carry credentials, and the platform checks them before the request reaches your model. Access to the endpoint is a permission on the endpoint itself, separate from privileges on the model in Unity Catalog. Endpoint permissions include roughly these levels:
- Can View: see the endpoint.
- Can Query: send scoring requests.
- Can Manage: change the configuration and permissions.
This separation matters in practice. A service that only scores data should have Can Query on the endpoint. It should not have rights on the registered model.
The model's own privileges still matter at deployment time. The person or service principal that creates the endpoint needs enough access to read the model, which is why the earlier chapter on EXECUTE and USE privileges comes before this one.
Governance
Because the endpoint points at a Unity Catalog model, the model's lineage and ownership stay in one place. The endpoint serves a specific version, so you can always say which registered version produced a given prediction.
Traffic splitting and updates
An endpoint can hold more than one served entity and divide traffic between them by percentage. You can send 90% of requests to the current version and 10% to a candidate. You can also replace the configuration, and Databricks keeps the previous configuration serving until the new one is ready, so clients see no gap. The update chapter shows how.
Observability
The platform exposes metrics such as request rate, latency, error rate and compute usage. It also keeps build and service logs for each served entity. You can optionally log requests and responses to a Unity Catalog table for later analysis, which Databricks calls inference tables.
Checking what exists
Before building an endpoint, it helps to see how endpoints appear through the SDK. This script lists the endpoints in your workspace and reports whether each is ready.
from databricks.sdk import WorkspaceClient
w = WorkspaceClient()
for endpoint in w.serving_endpoints.list():
ready = endpoint.state.ready if endpoint.state else None
print(endpoint.name, ready)The state field has two parts. ready tells you whether the endpoint can accept requests. config_update tells you whether a change is in progress. These two parts matter later. An endpoint can be ready and still be in the middle of a configuration update, because the old configuration keeps serving.
Limits to know about
Model Serving suits online prediction: one request or a small batch, and an answer in milliseconds to seconds. It has limits that affect design. The exact numbers change over time, so check the current documentation before relying on them.
- Payload size. Requests have a maximum size, currently 16 MB.
- Execution time. A request that runs too long is cut off. The current limit is about 300 seconds, which is far too long for any interactive use.
- Request rate. Each workspace has a default queries-per-second limit that you can ask to raise.
- Cold starts. With scale to zero, the first request after idling is slow.
For scoring millions of rows on a schedule, an endpoint is the wrong tool. Batch inference with a job that reads a table and writes predictions is cheaper and has no payload limit. Choose an endpoint when callers need an answer on demand.
| Need | Better fit |
|---|---|
| An application calls the model per user action | Serving endpoint |
| Score a full table nightly | Batch job using the registered model |
| Explore a model interactively | Notebook |
| Low latency with steady traffic | Serving endpoint with scale to zero off |
Common misunderstandings
- "The endpoint tracks the alias." An endpoint serves a fixed model version that you name in its configuration. Moving an alias such as
championdoes not change what the endpoint serves. You must update the endpoint to switch versions. This is covered in the update chapter. - "Registering a model deploys it." Registration stores the model. Nothing runs until you create an endpoint.
- "Model privileges are enough to query." Querying needs permission on the endpoint. Model privileges and endpoint permissions are separate.
- "Scale to zero is free of side effects." It saves cost when idle, and it adds start-up delay for the next request.
Where this fits in the workflow
The earlier chapters produced a registered model with a signature, a version, an alias and the right privileges. This chapter described the service that consumes it. The next chapter creates the endpoint with the SDK. Then you will authenticate, send a request shaped by the signature, and update the endpoint to a new version. Last, you will learn where to look when something fails.
Exercise
Your team moves the alias champion from version 1 to version 2 of main.default.iris_classifier. An endpoint was created earlier with entity_version="1". Which version does the endpoint serve now, and what must you do so that it serves version 2? Also name one reason you might keep the endpoint on version 1 for a while.
Show answer
The endpoint still serves version 1. An endpoint is configured with a fixed version, so moving an alias does not affect it. To serve version 2, update the endpoint configuration so the served entity has entity_version="2". Databricks keeps the old configuration serving until the new one is ready. You might hold version 1 while you validate version 2, or while you send it a small share of traffic through a second served entity before switching everyone over.
Exercise
A nightly job must score 40 million rows from a table and write the results back to a table. Should you use a serving endpoint? Give two reasons.
Show answer
No. Batch inference with a job that loads the registered model and reads and writes tables is a better fit. An endpoint has a maximum payload size and a per-request time limit, and sending 40 million rows through REST calls would add network overhead and hit the workspace's request-rate limit. A batch job scales with the data and has no such per-request limits.