Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Databricks · Databricks Machine Learning Associate

Model Serving endpoints and traffic splits

Databricks Machine Learning Associate · Lesson 18 of 19 · 2:23:02

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the Databricks Certified Machine Learning Associate exam. In this lesson: custom models and pyfunc wrappers, creating a Model Serving endpoint (workload sizes and scale to zero), querying it, and splitting traffic between a champion and a challenger. Includes three original practice questions.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

A price, and a test

The pricing model of Juniper Rides needs more than a library model: after the prediction, it must add a city surcharge, and round the price. The team wants it behind an endpoint for the app, and wants to try a new version on a small share of requests before switching. This lesson covers custom models, how to create a serving endpoint, how to query it, and how to split traffic between versions.

Custom models

Model Serving deploys custom models: Python models packaged in the MLflow format, like scikit-learn, XGBoost, or PyTorch models, logged with their built-in flavors. When the prediction needs extra logic, like a surcharge or rounding after the model, a pyfunc model wraps it: a class that inherits from PythonModel, with a predict method that holds the custom code. Its load_context method can load artifacts once, like a lookup file, when the model starts. The model is logged with a signature and its dependencies, then registered in Unity Catalog, which Databricks recommends. From there, a serving endpoint can serve it over HTTP, on CPU or GPU compute.

Creating an endpoint

An endpoint can be created from the Serving page, the REST API, the MLflow Deployments SDK, or the Databricks SDK. Its configuration lists served entities: each one names a registered model and a version, a workload size, Small, Medium, or Large, for the number of concurrent requests, and whether it scales to zero. Scale to zero saves money when traffic is low, but the first request after a quiet period waits for the compute to start again, so latency sensitive endpoints often keep it off. Endpoint names cannot start with databricks dash, a prefix reserved for endpoints that Databricks provides. And inference tables can capture the requests and responses of the endpoint in a Delta table, which the monitoring of lesson nineteen can use.

Querying an endpoint

Each endpoint is called over HTTP: a POST request to its invocations path, with a token for authentication. For a tabular model, the body holds a pandas DataFrame in JSON, and dataframe_split, the recommended format, sends the column names and the data separately, which keeps the column order. dataframe_records sends one object per row, but does not guarantee the column order, and tensor models take instances or inputs. The response holds the results, in a field named predictions. You can also query from the Serving page, with the predict method of the MLflow Deployments client, or from SQL, with ai_query.

Splitting traffic

One endpoint can serve several models, or several versions of one model, as separate served entities. The traffic configuration routes requests between them: each route names a served entity and its traffic percentage, and the percentages add up to one hundred. For example, the champion can get eighty percent of the requests, and a challenger twenty percent, to compare them on real traffic. Changing the endpoint configuration changes the split, for example to fifty and fifty, then one hundred percent for the new version, without changing the endpoint URL for the app. And a single served entity can be queried directly, through its own invocations path, to test it alone.

Recap

Let's recap. Custom models are Python models in the MLflow format, and a pyfunc model adds custom logic around a prediction. An endpoint lists served entities, each with a model version, a workload size, and a scale to zero setting, and inference tables capture its traffic. Clients send a POST request to the invocations path, with dataframe_split, the recommended format, and get back predictions. The traffic configuration splits requests between served entities, with percentages that add up to one hundred. And changing the split moves traffic to a new version, without changing the URL.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. The pricing model must add a city surcharge, read from a small file, after the scikit-learn prediction. How should the team package it?

    • The scikit-learn flavor, the file saved as a tag
    • Two endpoints, one per step, called in turn
    • A pyfunc model whose predict adds the surcharge
    • A Lakeflow job that rewrites each response
    Show the answer

    A pyfunc model whose predict adds the surcharge

    A pyfunc model wraps the scikit-learn model and the custom code, and load_context can read the file once, when the model starts. “The scikit-learn flavor, the file saved as a tag” is wrong, since tags hold short labels, not files that a model reads. “Two endpoints, one per step, called in turn” doubles the calls and the latency, for logic that fits in one model. And “A Lakeflow job that rewrites each response” runs after the fact, while the app needs the final price at once.

  2. A team builds requests for the pricing endpoint, and wants the column order of its rows preserved. Which input format does Databricks recommend?

    • dataframe_split
    • instances
    • Rows encoded in the URL
    • dataframe_records
    Show the answer

    dataframe_split

    Dataframe_split sends the column names and the data separately, which keeps the column order, and it is the recommended format. “instances” is meant for tensor inputs, like images, not for rows with named columns. “Rows encoded in the URL” is not how an endpoint receives its data. And “dataframe_records” does not guarantee the column order, which is why the split format is preferred.

  3. The team wants to send 20% of the price requests to a challenger version, without any change in the app. What should it set up?

    • A second endpoint, called by the app one time in five
    • Two aliases on the same model version
    • A tag that marks the challenger as active
    • Two served entities, with routes of 80 and 20
    Show the answer

    Two served entities, with routes of 80 and 20

    One endpoint serves both versions, and its traffic configuration sends eighty percent of the requests to the champion, and twenty to the challenger, behind the same URL. “A second endpoint, called by the app one time in five” would change the app, which would have to choose the endpoint itself. “Two aliases on the same model version” is wrong, since aliases point to versions, and route no traffic. And “A tag that marks the challenger as active” is wrong too, since tags only label a model or a version.