# Chalk CLI Reference: Traffic
source: https://docs.chalk.ai/cli#traffic

Control traffic routing between deployment versions. Manage [blue-green deployments](https://docs.chalk.ai/docs/blue-green-deployment), canary releases, and traffic mirroring.

## `chalk traffic get`
source: https://docs.chalk.ai/cli?command=traffic_get

```bash
chalk traffic get
```

Display the current traffic distribution and deployment IDs across tagged deployments.

Shows each deployment's tag, deployment ID, traffic weight percentage, and mirror weight.

**Example**

```
chalk traffic get
tags:
  - deployment_id: cm9n46thy000bwe6y784y4j0l
    tag: blue
    weight: 50
    mirror_weight: 10
  - deployment_id: cm9n3vx7c0004we6yefnsw8kg
    tag: green
    weight: 50
    mirror_weight: 0
```

## `chalk traffic set`
source: https://docs.chalk.ai/cli?command=traffic_set

```bash
chalk traffic set
```

Configure the traffic distribution between tagged deployments.

Set the percentage of traffic each deployment receives. Traffic weights should sum to 100. Deployments not specified in the command retain their current weights. Use this to gradually shift traffic during a rollout (e.g., 10% -> 50% -> 100%).

**Flags**

- `--tags <tags>` (string, default `map[]`)
  Traffic weights by tag name in the `blue=10,green=90` format.
- `--mirror <mirror>` (string, default `map[]`)
  Mirror weights by tag name in the `blue=10,green=5` format.

**Example**

```
chalk traffic set --tags blue=10,green=90 --mirror blue=5
tags:
  - deployment_id: cm9n46thy000bwe6y784y4j0l
    tag: blue
    weight: 10
    mirror_weight: 5
  - deployment_id: cm9n3vx7c0004we6yefnsw8kg
    tag: green
    weight: 90
    mirror_weight: 0
```

## `chalk traffic promote`
source: https://docs.chalk.ai/cli?command=traffic_promote

```bash
chalk traffic promote
```

Migrate 100% of traffic from the current active deployment to the inactive one.

This command finds the deployment tag (blue or green) with the lowest traffic weight and promotes it to 100%, setting the other to 0%. This enables quick rollbacks—if issues arise after a deployment, run this command again to shift traffic back.

**Example**

```
chalk traffic promote
tags:
  - deployment_id: cm9n46thy000bwe6y784y4j0l
    tag: blue
    weight: 100
  - deployment_id: cm9n3vx7c0004we6yefnsw8kg
    tag: green
    weight: 0
```

## `chalk traffic mirror`
source: https://docs.chalk.ai/cli?command=traffic_mirror

```bash
chalk traffic mirror
```

Route a percentage of production traffic to a deployment without affecting production responses.

Mirrored traffic is sent to the target deployment but responses are discarded—production users continue to receive responses from the primary deployment. This allows you to test new code under real traffic conditions without impacting users.

**Flags**

- `--mirror <mirror>` (string, default `map[]`)
  Mirror weights by tag name in the `blue=10,green=5` format.

**Example**

```
chalk traffic mirror --mirror blue=15,green=5
tags:
  - deployment_id: cm9n46thy000bwe6y784y4j0l
    tag: blue
    mirror_weight: 15
  - deployment_id: cm9n3vx7c0004we6yefnsw8kg
    tag: green
    mirror_weight: 5
```

## `chalk traffic suspend`
source: https://docs.chalk.ai/cli?command=traffic_suspend

```bash
chalk traffic suspend
```

Suspend a deployment by setting its traffic weight to nil.

Setting a deployment's weight to nil (rather than 0) signals that the deployment should be scaled down to save resources. Use this for deployments that are inactive and don't need to remain warm.

**Flags**

- `--deployment-tag <v1.4.3>` (string)
  The tag to add to the deployment.

**Example**

```
chalk traffic suspend --deployment-tag blue
tags:
  - deployment_id: cm9n46thy000bwe6y784y4j0l
    tag: blue
    weight: null
  - deployment_id: cm9n3vx7c0004we6yefnsw8kg
    tag: green
    weight: 100
```

## `chalk traffic readiness`
source: https://docs.chalk.ai/cli?command=traffic_readiness

```bash
chalk traffic readiness
```

Check that a deployment has ready replicas of each engine kind in every resource group whose services run it, including the default resource group. Use it before shifting traffic to a deployment: a resource group whose workload is empty (0/0) fails the check even if other services in that resource group are healthy.

A service is not ready while fewer than `--min-ready-fraction` (half by default) of its desired replicas are ready, so a deployment still starting most of its pods waits, while an autoscaler scale-up in progress does not fail the check. The resource groups come from the environment's current configuration, so resource groups added or removed since the last check are picked up.

Exits non-zero if the tag is suspended or unknown, if the tag does not route to `--deployment-id`, or if any expected service is not ready.

**Flags**

- `--deployment-tag <green>` (string)
  Check the deployment this tag currently routes to. Required unless --deployment-id is set.
- `--deployment-id <id>` (string)
  Check this deployment. With --deployment-tag, also fail unless the tag routes to it.
- `--service-kinds <service-kinds>` (string[], default `[engine-grpc engine]`)
  Service kinds to check. Each resource group is only checked for the kinds its own services list.
- `--min-ready-fraction <min-ready-fraction>` (duration, default `0.5`)
  Fraction of each workload's desired replicas that must be ready. The autoscaler adds pods over time, so this is below 1 to tolerate a scale-up in progress.

**Example**

```
$ chalk traffic readiness --deployment-tag green
Deployment cm9nasdfasdfafadsfadf (tag green, weight 0%)

  ✓ default_resource_group  engine-grpc  2/2 ready
  ✗ custom_resource_group   engine-grpc  0/0 ready  workload has 0 desired replicas
  - other_resource_group    engine-grpc  skipped    min_instances is 0

$ chalk traffic readiness --deployment-id cm9n46thy000bwe6y784y4j0l --service-kinds engine-grpc
```
