-
Notifications
You must be signed in to change notification settings - Fork 6
Scaling Docs #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Scaling Docs #148
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
sidebar_position: 550 | ||
title: Scaling Your Services | ||
description: How to scale services deployed with Defang | ||
--- | ||
|
||
# Scaling Your Services | ||
|
||
This tutorial will show you how to scale your services with Defang. | ||
|
||
There are two primary ways to scale a service. The first way is to increase the resources allocated to a service. For example, giving a service more CPUs or memory. The second way is to deploy multiple instances of a service. This is called scaling with replicas. Defang makes it easy to do both. | ||
|
||
The _Compose Specification_, which is used by defang, includes a [`deploy` section](https://github.com/compose-spec/compose-spec/blob/main/deploy.md) which allows you to configure the deployment configuration for a service. This includes your service's resource requirements and the number of replicas of a service should be deployed. | ||
|
||
## Scaling Resource Reservations | ||
|
||
In order to scale a service's resource reservations, you will need to update the `deploy` section associated with your service in your application's `compose.yaml` file. | ||
|
||
Use the [`resources`](https://github.com/compose-spec/compose-spec/blob/main/deploy.md#resources) section to specify the resource reservation requirements. These are the minimum resources which must be available for the platform to provision your service. You may end up with more resources than you requested, but you will never be allocated less. | ||
|
||
For example, if my app needs 2 CPUs and 512MB of memory, I would update the `compose.yaml` file like this: | ||
|
||
```yaml | ||
services: | ||
my_service: | ||
image: my_app:latest | ||
deploy: | ||
resources: | ||
reservations: | ||
cpus: '2' | ||
memory: '512M' | ||
``` | ||
|
||
The minimum resources which can be reserved: | ||
|
||
| Resource | Minimum | | ||
|----------|---------| | ||
| CPUs | 0.5 | | ||
| Memory | 512M | | ||
|
||
:::info | ||
Note that the `memory` field must be specified as a ["byte value string"](https://github.com/compose-spec/compose-spec/blob/main/11-extension.md#specifying-byte-values) using the `{amount}{byte unit}` format. The supported units are `b` (bytes), `k` or `kb` (kilo bytes), `m` or `mb` (mega bytes) and `g` or `gb` (giga bytes). | ||
jordanstephens marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
::: | ||
|
||
## Scaling with Replicas | ||
|
||
In order to scale a service's replica count, you will need to update the `deploy` section associated with your service in your application's `compose.yaml` file. | ||
|
||
Use the [`replicas`](https://github.com/compose-spec/compose-spec/blob/main/deploy.md#replicas) section to specify the number of containers which should be running at any given time. | ||
|
||
For example, if I want to run 3 instances of my app, I would update the `compose.yaml` file like this: | ||
|
||
```yaml | ||
services: | ||
my_service: | ||
image: my_app:latest | ||
deploy: | ||
replicas: 3 | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.