Skip to main content

Fix slow requests on Model Serving endpoints

If a Model Serving endpoint for custom models answers slowly or returns HTTP 429 errors under load, find your symptom in the table below, and go to the entry or page it names.

What you see

Usual cause

Go to

The first request after scale-up is slow, or it returns HTTP 555 on an endpoint scaled to zero.

The request waits while the endpoint scales up from zero.

Cold start after scale-up

HTTP 429 with the message "Too many concurrent requests."

One replica has more requests in progress than its concurrency limit.

Too many concurrent requests

HTTP 429 with a message that starts "Request rate increased too quickly."

The workspace has too many requests in progress at the same time.

Request rate increased too quickly

Requests slow down during sharp spikes and bursts.

A queue forms when requests arrive faster than the endpoint can process them.

Queuing and 429 errors under load

A request times out on an endpoint that's already running.

The request runs past the server-side limit.

Timeouts in Model Serving

What you see

Usual cause

Go to

The first request after scale-up is slow, or it returns HTTP 555 on an endpoint scaled to zero.

The request waits while the endpoint scales up from zero.

Cold start after scale-up

HTTP 429 with the message "Too many concurrent requests."

One replica has more requests in progress than its concurrency limit.

Too many concurrent requests

HTTP 429 with a message that starts "Request rate increased too quickly."

The workspace has too many requests in progress at the same time.

Request rate increased too quickly

Requests slow down during sharp spikes and bursts.

A queue forms when requests arrive faster than the endpoint can process them.

Queuing and 429 errors under load

A request times out on an endpoint that's already running.

The request runs past the server-side limit.

Timeouts in Model Serving

Requirements​

Run the cells in order, in one Databricks notebook, starting with this install cell. Run the update cells on a CPU endpoint that is already running.

Python
%pip install -U "mlflow>=3" "databricks-sdk>=0.102.0" scikit-learn pandas
dbutils.library.restartPython()

Replace <catalog> and <schema> with the catalog and schema that hold your model, and set MODEL and ENDPOINT_NAME to your model and endpoint.

Python
# Set these once. Use your own catalog and schema.
CATALOG = "<catalog>"
SCHEMA = "<schema>"
MODEL = "latency_demo_model"
ENDPOINT_NAME = "latency-demo"
FULL_MODEL_NAME = f"{CATALOG}.{SCHEMA}.{MODEL}"
# Leave as None unless the endpoint serves more than one version of the model.
SERVED_ENTITY_NAME = None

The update cells change only the scaling settings of the served entity that serves FULL_MODEL_NAME. They keep its version, name, and other settings, and they keep the endpoint's other served entities and its traffic split. If more than one served entity serves FULL_MODEL_NAME, such as two versions of the model, set SERVED_ENTITY_NAME to the name of the one to change. Otherwise the state read stops with an error.

Run the state read before each update, and start an update only when config_update reads NOT_UPDATING, because an update can't start while another is in progress.

Python
from databricks.sdk import WorkspaceClient

w = WorkspaceClient()
endpoint = w.serving_endpoints.get(name=ENDPOINT_NAME)
state = endpoint.state
print("state.ready:", state.ready.value)
print("state.config_update:", state.config_update.value)
matches = [
e for e in endpoint.config.served_entities
if e.entity_name == FULL_MODEL_NAME and SERVED_ENTITY_NAME in (None, e.name)
]
if len(matches) != 1:
raise ValueError(f"{len(matches)} served entities match. Set SERVED_ENTITY_NAME to the one to change.")
served = matches[0]
SERVED_ENTITY_NAME = served.name
print("scale_to_zero_enabled:", served.scale_to_zero_enabled)
print("min_provisioned_concurrency:", served.min_provisioned_concurrency)
print("max_provisioned_concurrency:", served.max_provisioned_concurrency)

The cell prints the following:

Text
state.ready: READY
state.config_update: NOT_UPDATING
scale_to_zero_enabled: True
min_provisioned_concurrency: None
max_provisioned_concurrency: None

None means the served entity shows no value for that field. An endpoint created with a workload size, such as Small, shows no concurrency values.

Define the helpers that the update cells use. update_scaling reads the endpoint's current config, changes only the fields you pass on the served entity named SERVED_ENTITY_NAME, and sends everything else back unchanged. current_limits returns that entity's minimum and maximum provisioned concurrency, and it computes the range from the workload size when the endpoint shows no concurrency values. To define them, run the following:

Python
from databricks.sdk.service.serving import ServedEntityInput

# The provisioned concurrency range of each workload size when scale to zero is off.
SIZE_LIMITS = {"Small": (4, 4), "Medium": (8, 16), "Large": (16, 64)}


def current_limits():
config = w.serving_endpoints.get(name=ENDPOINT_NAME).config
entity = next(e for e in config.served_entities if e.name == SERVED_ENTITY_NAME)
if entity.max_provisioned_concurrency is not None:
return entity.min_provisioned_concurrency or 0, entity.max_provisioned_concurrency
low, high = SIZE_LIMITS[entity.workload_size]
return (0 if entity.scale_to_zero_enabled else low), high


def update_scaling(**changes):
config = w.serving_endpoints.get(name=ENDPOINT_NAME).config
entities = []
for entity in config.served_entities:
entity_input = ServedEntityInput.from_dict(entity.as_dict())
if entity.name == SERVED_ENTITY_NAME:
for field, value in changes.items():
setattr(entity_input, field, value)
if entity_input.max_provisioned_concurrency is not None:
entity_input.workload_size = None # The concurrency fields can't be sent with workload_size.
entities.append(entity_input)
result = w.serving_endpoints.update_config_and_wait(
name=ENDPOINT_NAME, served_entities=entities, traffic_config=config.traffic_config
)
served = next(e for e in result.config.served_entities if e.name == SERVED_ENTITY_NAME)
print("config_update:", result.state.config_update.value)
print("scale_to_zero_enabled:", served.scale_to_zero_enabled)
print("min_provisioned_concurrency:", served.min_provisioned_concurrency)
print("max_provisioned_concurrency:", served.max_provisioned_concurrency)

Either update can fail at deployment. Then config_update reads UPDATE_FAILED, the endpoint keeps serving its previous configuration, and update_config_and_wait raises an OperationFailed error. For UPDATE_FAILED, see Endpoint update failed.

Cold start after scale-up​

A cold start is the extra latency a request sees while an endpoint scales back up from zero. A replica is one running instance of the model's serving container. This fix applies to custom model endpoints that autoscale.

The first request after scale-up is slow, or it returns HTTP 555​

A request that reaches an endpoint scaled to zero waits for a replica to start. On a CPU endpoint, the compute is scheduled, the image is pulled, the server starts, and the model loads. A GPU endpoint takes longer. If no replica is ready in time, the request fails with HTTP 555 and this message:

Text
The request exceeded the maximum allowed time and has timed out. This happens if the model server took too long to process the input (i.e., reduce input size) or the workload size is not enough to handle current load (i.e., increase compute scale-out

The same message appears for any request that runs too long.

Recommended solution: Keep at least one replica running. In one update, turn scale to zero off and set min_provisioned_concurrency to a multiple of 4 above 0. The trade-off is cost: the endpoint keeps those replicas running and billed at all times, even when it gets no traffic. The update below raises the minimum to at least 4, the smallest value above 0, and keeps the maximum at least as high. It keeps a maximum that you raised for 429 errors. On an endpoint that serves up to 4 requests at a time, it sets both to 4, so capacity stays fixed.

Run the following update:

Python
low, high = current_limits()
low = max(4, low)
update_scaling(scale_to_zero_enabled=False, min_provisioned_concurrency=low, max_provisioned_concurrency=max(low, high))

The update prints the following:

Text
config_update: NOT_UPDATING
scale_to_zero_enabled: False
min_provisioned_concurrency: 4
max_provisioned_concurrency: 4

Each update's output shows all three settings, so you can confirm the other fix is still in place.

Check: a request for traffic within the minimum you set doesn't wait for a cold start, so it gets no HTTP 555 error.

Queuing and 429 errors under load​

A replica accepts requests beyond what its workers can run at the same time, and those requests wait until a worker is free. A request past the replica's concurrency limit gets an HTTP 429 instead of waiting. A queue makes end-to-end latency longer, because each request waits before it is processed. Sudden traffic surges can cause queuing, because autoscaling takes time to detect load and add capacity.

Request queue time (ms) shows the median (P50) and 99th percentile (P99) time a request waits in the server's request backlog before a replica begins processing it. For the definition of each metric, see Review the metric definitions.

Recommended solution: For a burst you can plan for, raise the minimum or the maximum provisioned concurrency before the burst. Use the update in Cold start after scale-up or in Too many concurrent requests.

The following entries cover two of the HTTP 429 messages that Model Serving returns.

Too many concurrent requests​

You might get an HTTP 429 error with this message:

Text
Too many concurrent requests. Consider increasing the provisioned concurrency of the served entity.

This error occurs when one replica has more requests in progress than its concurrency limit. Each replica has its own limit, so one busy replica can return this error while other replicas have room. The per-replica limit can't be changed. Autoscaling doesn't act on 429 responses, and it adds replicas only up to the maximum.

Recommended solution: Raise the maximum provisioned concurrency to add replicas. The update below raises the maximum by 4, to at least 8, so it never lowers it. To use another maximum, pass a multiple of 4. To size an endpoint for a traffic target, see Size and load test custom model serving endpoints.

The update keeps the current minimum and the scale to zero setting, so it keeps the cold-start fix if you applied it. The output below is for an endpoint that has scale to zero on and serves up to 4 requests at a time. To raise the maximum, run the following update:

Python
low, high = current_limits()
update_scaling(min_provisioned_concurrency=low, max_provisioned_concurrency=max(8, high + 4))

The update prints the following:

Text
config_update: NOT_UPDATING
scale_to_zero_enabled: True
min_provisioned_concurrency: 0
max_provisioned_concurrency: 8

Check: the Too many concurrent requests message stops appearing after the requests in progress on each replica stay within its limit.

Request rate increased too quickly​

You might get an HTTP 429 error whose message starts with this sentence:

Text
Request rate increased too quickly.

This error occurs when the workspace has too many requests in progress at the same time, and it isn't a limit on requests per second.

Recommended solution: Send fewer requests at the same time, or spread them out over time. Model Serving doesn't retry a 429, so the client has to retry it with exponential backoff.

Check: requests succeed again when the requests in progress from the workspace drop below the level that caused this error.

Additional resources​