Sub topic 12
Rolling an endpoint forward to a new version
This chapter assumes you have a registered model with at least one version, an alias such as champion, and a running endpoint like the iris-endpoint from the earlier chapters. You should also be comfortable with the Databricks SDK client (WorkspaceClient). By the end you will be able to move an endpoint to a new model version without downtime, split traffic between versions, and roll back.
What "updating" means for an endpoint
A serving endpoint has a configuration. The configuration lists one or more served entities, and each served entity points at one registered model version. When you train a better model and register it, Unity Catalog creates version 2 of main.default.iris_classifier. Nothing happens to the endpoint. It keeps serving version 1 until you change its configuration.
Updating an endpoint means submitting a new configuration. Databricks builds the new configuration in the background while the current one keeps answering requests. When the new one is ready, traffic switches over. If the build fails, the old configuration stays active.
Aliases do not move endpoints by themselves
The earlier chapter on aliases showed that models:/main.default.iris_classifier@champion resolves to a version at load time. A serving endpoint does not work that way. The served entity takes a version number in entity_version. If you later move the champion alias from version 1 to version 2, the endpoint still serves version 1.
This is a common source of confusion. Treat the alias as the team's record of which version is approved, and treat the endpoint update as the step that deploys it. A reliable pattern is to resolve the alias to a number in the deployment script and pass that number to the endpoint.
import mlflow
from mlflow import MlflowClient
mlflow.set_registry_uri("databricks-uc")
client = MlflowClient()
MODEL_NAME = "main.default.iris_classifier"
# Resolve the alias to a concrete version number
champion = client.get_model_version_by_alias(MODEL_NAME, "champion")
print(f"champion is version {champion.version}")Keeping this lookup in code gives you one source of truth. The deployment always ships whatever champion currently names, and the printed version number goes into your deployment log.
Updating to a new version
Use update_config_and_wait. It sends the new configuration and blocks until the endpoint reports that the update has finished.
from databricks.sdk import WorkspaceClient
from databricks.sdk.service.serving import ServedEntityInput
w = WorkspaceClient()
w.serving_endpoints.update_config_and_wait(
name="iris-endpoint",
served_entities=[
ServedEntityInput(
entity_name="main.default.iris_classifier",
entity_version="2",
workload_size="Small",
scale_to_zero_enabled=True,
)
],
)Three details matter here.
- The update replaces the whole configuration. It is not a patch. If the endpoint had two served entities and you submit one, the other is removed. Always submit the complete list of entities you want after the update.
entity_versionis a string, as in the create call.- Compute settings are part of the configuration. If you leave out
workload_sizeorscale_to_zero_enabled, you get the defaults, not the values from the previous configuration. Repeat the settings you want to keep.
An endpoint accepts only one update at a time. If an update is still in progress and you submit another, the request is rejected. Wait for the first to finish, or check the state before submitting.
Checking update state
The endpoint object reports two things you care about: whether it is ready, and whether a configuration update is running.
endpoint = w.serving_endpoints.get("iris-endpoint")
print("ready:", endpoint.state.ready.value)
print("config update:", endpoint.state.config_update.value)ready is READY when the endpoint can take requests. config_update is IN_PROGRESS while a new configuration builds and NOT_UPDATING otherwise. During an update the new configuration appears in endpoint.pending_config while endpoint.config still shows what is serving. A config_update value of UPDATE_FAILED means the build did not succeed. In that case config is still the old, working configuration, and the endpoint event logs hold the reason.
A short polling loop is useful when you submit the update without waiting, for example from a job that must do other work:
import time
while True:
state = w.serving_endpoints.get("iris-endpoint").state
if state.config_update.value != "IN_PROGRESS":
break
time.sleep(15)
print("final config_update:", state.config_update.value)For most scripts, update_config_and_wait already does this for you and raises an error if the update fails.
Splitting traffic between versions
Switching all traffic at once is simple, but it exposes every request to the new model immediately. A safer option is a canary release. You serve both versions in one endpoint and route a small share of traffic to the new one.
To do this, give each served entity a unique name and add a traffic configuration. The percentages must add up to 100.
from databricks.sdk import WorkspaceClient
from databricks.sdk.service.serving import (
Route,
ServedEntityInput,
TrafficConfig,
)
w = WorkspaceClient()
w.serving_endpoints.update_config_and_wait(
name="iris-endpoint",
served_entities=[
ServedEntityInput(
name="iris-v1",
entity_name="main.default.iris_classifier",
entity_version="1",
workload_size="Small",
scale_to_zero_enabled=True,
),
ServedEntityInput(
name="iris-v2",
entity_name="main.default.iris_classifier",
entity_version="2",
workload_size="Small",
scale_to_zero_enabled=True,
),
],
traffic_config=TrafficConfig(
routes=[
Route(served_model_name="iris-v1", traffic_percentage=90),
Route(served_model_name="iris-v2", traffic_percentage=10),
]
),
)The route fields refer to the entity names you chose, not to model versions. If you omit name, Databricks generates one from the model and version, for example iris_classifier-2. Setting names yourself keeps the traffic config readable and stable.
Traffic is assigned per request, so a single client can see answers from both versions. This is fine for independent predictions. It is a problem for any workflow that expects consistent results across consecutive calls.
Once the 10% slice looks healthy, run another update. Send 100% to iris-v2 or drop iris-v1 from the list. Removing an entity that still has a route gives a validation error, so change the routes and the entity list in the same call.
Rolling back
Rolling back is another update. Submit a configuration that names the previous version.
w.serving_endpoints.update_config_and_wait(
name="iris-endpoint",
served_entities=[
ServedEntityInput(
entity_name="main.default.iris_classifier",
entity_version="1",
workload_size="Small",
scale_to_zero_enabled=True,
)
],
)A rollback also goes through the build step, so it is not instant. For a fast cutover, keep the old entity in the endpoint during a canary and move the traffic percentage back to it. A traffic change on entities that already exist is quicker than building a new entity.
The registry side needs tidying as well. After a rollback, move the champion alias back to the older version so the registry and the endpoint agree:
client.set_registered_model_alias(MODEL_NAME, "champion", 1)Things that go wrong during an update
| Symptom | Likely cause | Where to look |
|---|---|---|
| Update rejected immediately | Another update is still in progress | `state.config_update` on the endpoint |
| Update ends in `UPDATE_FAILED` | The new version's container failed to build or start, for example a missing dependency | The endpoint's event and build logs |
| Permission error on update | The caller lacks permission to manage the endpoint, or lacks access to the model | Endpoint permissions and `EXECUTE` on the model |
| Clients get changed output after the update | The new version has a different signature or behavior | The model signature of each version |
| First request after the update is slow | Scale to zero left no running compute | Latency of the first call, then steady state |
The signature row deserves attention. A new version with a different input schema can break clients that worked against version 1, because the endpoint validates request payloads against the signature. Compare the signatures of the two versions before you deploy, and treat a changed input schema as a breaking change that needs a new endpoint or a coordinated client update.
for version in (1, 2):
mv = client.get_model_version(MODEL_NAME, str(version))
info = mlflow.models.get_model_info(f"models:/{MODEL_NAME}/{mv.version}")
print(version, info.signature.inputs)Verifying after the update
Do not stop at a successful update call. A ready endpoint can still return bad predictions. Send a known row through the endpoint and compare the result with what you expect from the new version. Reuse the request from the previous chapter, with the same dataframe_split payload, and check that the response contains a predictions field. Then look at the endpoint's metrics for request rate, error rate and latency over the next several minutes. The next chapter covers those views in detail.
Exercise
You move the champion alias from version 1 to version 2 of main.default.iris_classifier. The endpoint iris-endpoint was created with entity_version="1". Which version does the endpoint serve now, and what must you do to change it?
Show answer
It still serves version 1. Endpoints store a version number, not an alias, so moving the alias does not affect them. Resolve the alias to a version number (for example with get_model_version_by_alias) and call update_config_and_wait with entity_version set to that number, repeating the workload size and scale to zero settings you want to keep.
Exercise
You want to send 5% of traffic to version 3 while 95% stays on version 2. What must you set on the served entities and in the traffic configuration, and what must the percentages sum to?
Show answer
Submit one update with two served entities, each with a unique name (for example iris-v2 and iris-v3) pointing at versions 2 and 3. Add a TrafficConfig with two Route entries that use those names as served_model_name, with traffic_percentage values of 95 and 5. The percentages must sum to 100.