> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baseten.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Scale a deployment

> Update a live deployment's autoscaling settings, scale to zero, and wake a scaled-to-zero deployment with the Management API.

Scale your deployments as traffic hits your endpoint. Traffic can change
faster than you can react to it: pre-scale ahead of the spikes you can see
coming, and let the [autoscaler](/deployment/autoscaling/overview) absorb
the ones you can't.

This page covers applying scaling changes to a live deployment. To choose
the values themselves, start with the
[autoscaling overview](/deployment/autoscaling/overview) and match the
settings to your [traffic patterns](/deployment/autoscaling/traffic-patterns).

## Update autoscaling settings

Update autoscaling settings in place to pre-scale for a known traffic spike,
raise a replica ceiling, or tune scale-down behavior. The change applies to
the running deployment; replicas adjust without a new deploy.

<Tabs>
  <Tab title="UI">
    **To update autoscaling settings**:

    1. Sign in to your workspace at
       [app.baseten.co](https://app.baseten.co) and choose **Dedicated Inference** in the
       sidebar.
    2. Select your model.
    3. On the model's overview, choose **Configure** under the environment's
       **Replicas**.
    4. Adjust your settings:
       * **Replicas**: the minimum and maximum replica count. Baseten
         scales within this range based on traffic.
       * **Autoscaling window**: how far back the autoscaler looks when
         averaging traffic for scaling decisions.
       * **Scale down delay**: how long the autoscaler waits after traffic
         drops before removing replicas.
       * **Max scale down rate**: the largest percentage of active replicas
         the autoscaler removes in a single scale-down step.
       * **Concurrency target**: the number of concurrent requests each
         replica handles before the autoscaler adds another.
       * **Target utilization percentage**: the share of the concurrency
         target at which scaling triggers.
    5. Choose **Update** to apply the changes.

    The same dialog is in the environment card's **⋯** menu as
    **Configure autoscaling**.
  </Tab>

  <Tab title="REST API">
    **To update autoscaling settings**:

    Use the `autoscaling_settings` endpoint to apply autoscaling updates.
    It accepts any subset of the fields, so send only the ones you're
    changing; the update applies asynchronously:

    <CodeGroup>
      ```bash Request theme={"system"}
      curl -X PATCH "https://api.baseten.co/v1/models/{model_id}/deployments/{deployment_id}/autoscaling_settings" \
        -H "Authorization: Bearer $BASETEN_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "min_replica": 2,
          "max_replica": 8,
          "autoscaling_window": 60,
          "scale_down_delay": 900,
          "concurrency_target": 2,
          "target_utilization_percentage": 70
        }'
      ```

      ```json Response theme={"system"}
      {
        "status": "ACCEPTED",
        "message": "Your request to update autoscaling settings has been accepted. Query for deployment {deployment_id}'s status to see when the updates have been applied."
      }
      ```
    </CodeGroup>
  </Tab>
</Tabs>

Now that your deployment's settings are updated, verify the changes reached
the deployment. The update applies asynchronously, so the new values can
take a moment to land:

<Tabs>
  <Tab title="UI">
    **To verify your settings**:

    1. Sign in to your workspace at
       [app.baseten.co](https://app.baseten.co) and choose **Dedicated Inference** in the
       sidebar.
    2. Select your model.
    3. Select the deployment under **Deployments**.
    4. Review the current values on the **Autoscaling settings** card:
       replicas, autoscaling window, scale down delay, concurrency target,
       and target utilization.
  </Tab>

  <Tab title="Baseten CLI">
    **To verify your settings**:

    <CodeGroup>
      ```bash Command theme={"system"}
      baseten model deployment describe --model-id <model-id> --deployment-id <deployment-id> --jq '.autoscaling_settings'
      ```

      ```json Output theme={"system"}
      {
        "autoscaling_window": 60,
        "concurrency_target": 2,
        "max_replica": 8,
        "min_replica": 2,
        "scale_down_delay": 900,
        "target_utilization_percentage": 70
      }
      ```
    </CodeGroup>
  </Tab>

  <Tab title="REST API">
    **To verify your settings**:

    <CodeGroup>
      ```bash Request theme={"system"}
      curl "https://api.baseten.co/v1/models/{model_id}/deployments/{deployment_id}" \
        -H "Authorization: Bearer $BASETEN_API_KEY"
      ```

      ```json Response theme={"system"}
      {
        "id": "def456",
        "autoscaling_settings": {
          "min_replica": 2,
          "max_replica": 8,
          "autoscaling_window": 60,
          "scale_down_delay": 900,
          "concurrency_target": 2,
          "target_utilization_percentage": 70
        },
        ...
      }
      ```
    </CodeGroup>
  </Tab>
</Tabs>

For more information, see the
[update autoscaling settings endpoint](/reference/management-api/deployments/autoscaling/updates-a-deployments-autoscaling-settings).
To update settings on whatever deployment an environment currently serves, use
the [environment settings endpoint](/reference/management-api/environments/update-an-environments-settings)
instead.

## Scale back down

After a spike passes, lower `min_replica` back to its normal floor with the
same [update procedure](#update-autoscaling-settings). Two settings control
how fast replicas drain:

* **Scale down delay** (`scale_down_delay`): how long the autoscaler waits
  after traffic drops before removing replicas.
* **Max scale down rate**: the largest percentage of active replicas removed
  in a single step. Set it in the console's **Configure autoscaling**
  dialog.

For example, drop the floor back to one replica and keep a 15-minute drain
delay:

<CodeGroup>
  ```bash Request theme={"system"}
  curl -X PATCH "https://api.baseten.co/v1/models/{model_id}/deployments/{deployment_id}/autoscaling_settings" \
    -H "Authorization: Bearer $BASETEN_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"min_replica": 1, "scale_down_delay": 900}'
  ```

  ```json Response theme={"system"}
  {
    "status": "ACCEPTED",
    "message": "Your request to update autoscaling settings has been accepted. Query for deployment {deployment_id}'s status to see when the updates have been applied."
  }
  ```
</CodeGroup>

Replicas above the new floor drain gradually; traffic keeps flowing to the
replicas that remain.

## Scale to zero

Set `min_replica` to `0` to let an idle deployment release all its replicas
and stop billing for compute.

<Note>
  Scaling to zero isn't recommended for production endpoints: the first
  request after an idle period pays a [cold start](/deployment/autoscaling/cold-starts).
  Reserve it for development and staging deployments, or for workloads that
  tolerate the delay.
</Note>

<Tabs>
  <Tab title="UI">
    **To scale to zero**:

    1. Sign in to your workspace at
       [app.baseten.co](https://app.baseten.co) and choose **Dedicated Inference** in the
       sidebar.
    2. Select your model.
    3. On the model's overview, choose **Configure** under the environment's
       **Replicas**.
    4. Set **Min** replicas to `0`.
    5. Choose **Update** to apply the changes.
  </Tab>

  <Tab title="REST API">
    **To scale to zero**:

    <CodeGroup>
      ```bash Request theme={"system"}
      curl -X PATCH "https://api.baseten.co/v1/models/{model_id}/deployments/{deployment_id}/autoscaling_settings" \
        -H "Authorization: Bearer $BASETEN_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{"min_replica": 0}'
      ```

      ```json Response theme={"system"}
      {
        "status": "ACCEPTED",
        "message": "Your request to update autoscaling settings has been accepted. Query for deployment {deployment_id}'s status to see when the updates have been applied."
      }
      ```
    </CodeGroup>
  </Tab>
</Tabs>

The model's endpoint stays live, and the next request spins a replica back
up. To stop serving entirely,
[deactivate the deployment](/deployment/manage/lifecycle#deactivate-a-deployment)
instead.

## Wake a scaled-to-zero deployment

Wake a scaled-to-zero deployment before you need it, for example ahead of a
demo or a batch job, so the first real request doesn't pay the cold start.

<Tabs>
  <Tab title="UI">
    **To wake a deployment**:

    1. Sign in to your workspace at
       [app.baseten.co](https://app.baseten.co) and choose **Dedicated Inference** in the
       sidebar.
    2. Select your model.
    3. Select the deployment under **Deployments**.
    4. Choose **Wake deployment**.

    The environment card has the same action as **Wake**.
  </Tab>

  <Tab title="REST API">
    **To wake a deployment**:

    <CodeGroup>
      ```bash Request theme={"system"}
      curl -i -X POST "https://model-{model_id}.api.baseten.co/deployment/{deployment_id}/wake" \
        -H "Authorization: Bearer $BASETEN_API_KEY"
      ```

      ```txt Response theme={"system"}
      HTTP/2 202
      content-length: 0
      ```
    </CodeGroup>
  </Tab>
</Tabs>

The deployment
starts a replica in the background, moving from `SCALED_TO_ZERO` through
`WAKING_UP` to `ACTIVE`; poll
[`baseten model deployment describe`](/reference/cli/baseten/model-deployment#describe)
until `status` is `ACTIVE`.

A woken deployment with `min_replica: 0` scales back down after
`scale_down_delay` if no requests arrive, so wake it close to when you need
it, or [raise `min_replica`](#update-autoscaling-settings) to hold it warm.

## Next steps

Scaling changes take effect on the running deployment, so pair them with a
quick status check before and after.

* [Autoscaling overview](/deployment/autoscaling/overview) to choose replica
  counts, concurrency targets, and scale-down behavior.
* [Manage the deployment lifecycle](/deployment/manage/lifecycle) to
  deactivate, promote, or delete deployments.
* [Pull logs and metrics](/deployment/manage/logs-and-metrics) to confirm how
  a scaling change lands.
