This page shows you how to deploy a new version of your application and migrate
traffic over from an old to a new version.

## Push the initial App

Use the Kf CLI to push the initial version of your App
with any routes:

```bash
$ kf push app-v1 --route my-app.my-space.example.com
```

## Push the updated App

Use the Kf CLI to push a new version of your App without
any routes:

```bash
$ kf push app-v2 --no-route
```

## Add routes to the updated App

Use the Kf CLI to bind all existing routes to the updated
App with a weight of 0 to ensure that they don't get any requests:

```bash
$ kf map-route app-v2 my-space.example.com --hostname my-app --weight 0
```

## Shift traffic

Start shifting traffic from the old App to the updated App by updating the
weights on the routes:

```bash
$ kf map-route app-v1 my-space.example.com --hostname my-app --weight 80
$ kf map-route app-v2 my-space.example.com --hostname my-app --weight 20
```

If the deployment is going well, you can shift more traffic by updating the
weights again:

```bash
$ kf map-route app-v1 my-space.example.com --hostname my-app --weight 50
$ kf map-route app-v2 my-space.example.com --hostname my-app --weight 50
```

> [!NOTE]
> **Note:** Weights split traffic proportionally to the sum of the weights of all Apps mapped to the route. It's a common practice to treat weights as percentages.

## Complete traffic shifting

After you're satisfied that the new service hasn't introduced regressions,
complete the rollout by shifting all traffic to the new instance:

```bash
$ kf map-route app-v1 my-space.example.com --hostname my-app --weight 0
$ kf map-route app-v2 my-space.example.com --hostname my-app --weight 100
```

## Turn down the original App

After you're satisfied that quick rollbacks aren't needed, remove the original
route and stop the App:

```bash
$ kf unmap-route app-v1 myspace.example.com --hostname my-app
$ kf stop app-v1
```

Or delete the App and all associated route mappings:

```bash
$ kf delete app-v1
```