Route optimization for Model Serving endpoints

Enable route optimization on a model serving or feature serving endpoint to lower overhead latency and raise the throughput it supports. This page covers how to turn it on and which endpoints support it.

Route-optimized endpoints are queried differently from non-route-optimized endpoints, including using a different URL and authentication using OAuth tokens. See Query route-optimized serving endpoints for details.

What is route optimization?

When you enable route optimization on an endpoint, Databricks Model Serving uses a more direct network path for inference requests between your client and the model. This raises the queries per second (QPS) that the endpoint supports compared with a non-optimized endpoint. It also gives your applications more stable and lower latency.

Tip

Route optimization is one of several strategies for optimizing production workloads. For when to use route optimization and for other optimization techniques, see Optimize Model Serving endpoints for production.

Requirements

Enable route optimization on a model serving endpoint

You can turn on route optimization only when you create an endpoint. You can't update an existing endpoint to be route optimized. To use route optimization on an existing endpoint, create a new endpoint with it turned on.

To create the endpoint with route optimization turned on, set route_optimized in the create call. Install the Databricks SDK for Python with pip install databricks-sdk. The following example uses it:

from databricks.sdk import WorkspaceClient
from databricks.sdk.service.serving import EndpointCoreConfigInput, ServedEntityInput

workspace = WorkspaceClient()

workspace.serving_endpoints.create(
  name="my-serving-endpoint",
  config = EndpointCoreConfigInput(
    name="my-serving-endpoint",
    served_entities=[
    ServedEntityInput(
        entity_name="main.default.my-served-entity",
        entity_version="1",
        scale_to_zero_enabled=True,
        workload_size="Small"
      )
    ]
  ),
  route_optimized=True
)

Replace main.default.my-served-entity and the entity_version value with your model's name and version.

The call starts the create and returns a waiter, so the endpoint isn't ready yet. After it's ready, its endpoint_url field holds the URL to query. See Query route-optimized serving endpoints.

To turn on route optimization in the Serving UI instead, follow the steps in Create an endpoint. In the Route optimization section, select Enable route optimization when you create the endpoint. After your endpoint is created, the endpoint page shows a banner about what is needed to query a route optimized endpoint.

Serving UI create form with the Route optimization section and its Enable route optimization checkbox

To set the same field with the REST API, add "route_optimized": true to the request body of the create serving endpoint call.

To create the endpoint from a notebook instead, open the following notebook:

Create a route optimized serving endpoint using Python notebook

Get notebook

Enable route optimization on a feature serving endpoint

To use route optimization for Feature and Function Serving, specify the full name of the feature specification in the entity_name field for serving endpoint creation requests. The entity_version is not needed for FeatureSpecs.


POST /api/2.0/serving-endpoints

{
  "name": "my-endpoint",
  "config":
  {
    "served_entities":
    [
      {
        "entity_name": "catalog_name.schema_name.feature_spec_name",
        "workload_type": "CPU",
        "workload_size": "Small",
        "scale_to_zero_enabled": true
      }
    ]
  },
  "route_optimized": true
}

Limitations

  • Route optimization is only available for custom model serving endpoints and feature serving endpoints. Serving endpoints that use Foundation Model APIs or external models are not supported.
  • Agent serving endpoints can't use route optimization.
  • Custom LLM endpoints can't use route optimization.
  • Databricks in-house OAuth tokens are the only supported authentication for route optimization. Personal access tokens are not supported.

Additional resources

Resource Description
Query route-optimized serving endpoints Query a route-optimized endpoint with an OAuth token.
Optimize Model Serving endpoints for production Optimize endpoints for production workloads.