# Configure request priorities

To prioritize some traffic to a Bigtable table over other traffic, you
can specify an app profile's *request priority*. Bigtable uses the
specified request priority to determine the order in which it executes requests.

## Priority levels

All requests sent to Bigtable use an *app profile* , which stores
settings that tell your Bigtable instance how to handle incoming
requests. To understand how they work, see
[App profiles overview](https://docs.cloud.google.com/bigtable/docs/app-profiles).

You can specify the following request priorities in an app profile:

- High
- Medium
- Low

Higher priority requests are likely to run before lower priority requests.

If you don't specify a priority, all requests are considered high priority by
default.

> [!NOTE]
> **Note:** Bigtable's scheduling of high priority requests favors operations that take less time to complete, such as simple, single-row read requests that return small payloads on the order of kilobytes.

## Base priority level on workload type

Specify high priority for app profiles that you use for latency-sensitive,
serving-path workloads.

Specify medium or low priority for app profiles that you use for workloads that
you want to run without impacting the performance of high priority requests. For
example, you can make batch read analytics a low priority so that traffic
doesn't compete with application-serving traffic that you designate as high
priority.

Specify low priority for batch jobs that use [batch write flow
control](https://docs.cloud.google.com/bigtable/docs/writes#flow-control).

## Monitor CPU utilization

When you send a mix of high, medium, or low priority traffic, be sure to keep
your clusters' CPU utilization below the recommended maximum values.
Maintaining lower CPU utilization ensures that lower priority requests aren't
[starved](https://en.wikipedia.org/wiki/Starvation_(computer_science)).
To review the recommended maximums, see [Plan your capacity](https://docs.cloud.google.com/bigtable/docs/performance#planning-your-capacity).

## Configure request priorities

You must use the Google Cloud CLI to specify request
priorities. To ensure that you have the most recent version of the
gcloud CLI, run the following:

    gcloud components update

When you execute the gcloud CLI commands, replace the following:

- `APP_PROFILE_ID` - The permanent identifier for the app profile.
- `INSTANCE_ID` - The permanent identifier for the instance.
- `PRIORITY_LEVEL` - The priority level that the app profile uses. Accepted values are `PRIORITY_HIGH`, `PRIORITY_MEDIUM`, or `PRIORITY_LOW`.

### Specify a request priority when creating a new app profile

To create an app profile with a specified request priority, run the following
command. For the complete list of additional positional arguments and flags that
you can use with this command, see [`gcloud bigtable app-profiles
create`](https://docs.cloud.google.com/sdk/gcloud/reference/bigtable/app-profiles/create).

    gcloud bigtable app-profiles create APP_PROFILE_ID \
        --instance=INSTANCE_ID \
        --route-any \
        --priority=PRIORITY_LEVEL

### Add or change an app profile's request priority

To update the priority of an existing app profile, run the following
command. For the complete list of additional positional arguments and flags that
you can use with this command,
see [`gcloud bigtable app-profiles
update`](https://docs.cloud.google.com/sdk/gcloud/reference/bigtable/app-profiles/update).

    gcloud bigtable app-profiles update APP_PROFILE_ID \
        --instance=INSTANCE_ID \
        --route-any \
        --priority=PRIORITY_LEVEL

To stop using request priorities for a table, run the command to set the
priority to `PRIORITY_HIGH` for every app profile that your applications use to
send requests to the table.

## What's next

- [See examples of replication settings](https://docs.cloud.google.com/bigtable/docs/replication-settings)
- [Review write-request types](https://docs.cloud.google.com/bigtable/docs/writes)