Skip to content

Commit 20a4229

Browse files
committed
[Docs]: Service rolling deployments
1 parent 7d999e1 commit 20a4229

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

docs/docs/concepts/services.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,52 @@ utilization_policy:
681681

682682
--8<-- "docs/concepts/snippets/manage-runs.ext"
683683

684+
## Deployments
685+
686+
To deploy a new version of the service, change its configuration or associated resources, such as files or repo contents. Then, re-run `dstack apply`.
687+
688+
<div class="termy">
689+
690+
```shell
691+
$ dstack apply -f my-service.dstack.yml
692+
693+
Active run my-service already exists. Detected changes that can be updated in-place:
694+
- Repo state (branch, commit, or other)
695+
- File archives
696+
- Configuration properties:
697+
- env
698+
- files
699+
700+
Update the run? [y/n]:
701+
```
702+
703+
</div>
704+
705+
If `dstack` can apply all the detected changes without a full service restart, it starts a rolling deployment. During the rolling deployment, `dstack` gradually updates the service replicas to the new version. First, it starts an extra replica. Then, it waits until this replica enters the `running` state. Finally, it terminates the old replica.
706+
707+
During deployment, new and old replicas can coexist and handle requests simultaneously. If the service has multiple replicas, they are updated one by one &mdash; there can be at most one extra replica above the desired number of replicas, as determined by the `replicas` and `scaling` properties.
708+
709+
You can track the deployment progress in the `dstack apply` output. The `deployment` number will be lower for old replicas and higher for new ones.
710+
711+
```shell
712+
$ dstack apply -f my-service.dstack.yml
713+
714+
⠋ Launching my-service...
715+
NAME BACKEND PRICE STATUS SUBMITTED
716+
my-service deployment=1 running 11 mins ago
717+
replica=0 job=0 deployment=0 aws (us-west-2) $0.0026 terminating 11 mins ago
718+
replica=1 job=0 deployment=1 aws (us-west-2) $0.0026 running 1 min ago
719+
```
720+
721+
A deployment stops either when all of the replicas are up to date or when the next deployment is submitted.
722+
723+
<!-- NOTE: should be in sync with constants in server/services/runs.py -->
724+
725+
Rolling deployments apply to the following configuration properties: `resources`, `volumes`, `docker`, `files`, `image`, `user`, `privileged`, `entrypoint`, `working_dir`, `python`, `nvcc`, `single_branch`, `env`, `shell`, `commands`. They also apply to changes to [repo](repos.md) or [file](#files) contents.
726+
727+
??? info "Forcing a redeployment"
728+
Sometimes you may want to run a rolling deployment even if `dstack` detects no changes to the configuration or associated resources. This can be useful if you've changed the project [secrets](secrets.md) or if you just want to gradually restart all service replicas. Currently, this can be achieved by making an insignificant change to the configuration, such as adding a dummy [environment variable](#environment-variables).
729+
684730
!!! info "What's next?"
685731
1. Read about [dev environments](dev-environments.md), [tasks](tasks.md), and [repos](repos.md)
686732
2. Learn how to manage [fleets](fleets.md)

src/dstack/_internal/server/services/runs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ def _validate_run_spec_and_set_defaults(run_spec: RunSpec):
930930
"replicas",
931931
"scaling",
932932
# rolling deployment
933+
# NOTE: keep this list in sync with the "Deployments" section in services.md
933934
"resources",
934935
"volumes",
935936
"docker",

0 commit comments

Comments
 (0)