-
Notifications
You must be signed in to change notification settings - Fork 894
docs: add new best practice doc to speed up templates and workspaces #15296
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
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3886e0b
speed up templates and workspaces
EdwardAngert 4a42588
update screenshot
EdwardAngert 3073ab7
make fmt
EdwardAngert 30417eb
add speed up to manifest
EdwardAngert 2df6c0b
add index to best practices
EdwardAngert 00d394b
description to manifest
EdwardAngert 913c6ca
Update docs/tutorials/best-practices/speed-up-templates.md
EdwardAngert 0725931
suggestions from code review
EdwardAngert 209671d
typo fix
EdwardAngert 5a0ab2a
move build timeline up in monitoring
EdwardAngert 4d3b220
typo fix
EdwardAngert 348fcbb
Update docs/tutorials/best-practices/speed-up-templates.md
bpmct 3ff3499
add intro sentence to bp category index
EdwardAngert 046a07b
suggestions from code review
EdwardAngert 4b4032f
make fmt
EdwardAngert 869ac35
md tweak to k8s doc
EdwardAngert 858fb12
make fmt
EdwardAngert 6ad8e41
md tweak to k8s doc
EdwardAngert 62deabc
add observability chart to k8s
EdwardAngert 72dd419
typo fix
EdwardAngert 460ef1e
Apply suggestions from code review
EdwardAngert baf32ae
Update docs/tutorials/best-practices/speed-up-templates.md
EdwardAngert 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
Next
Next commit
speed up templates and workspaces
- Loading branch information
commit 3886e0b21bf192cb2baab45ff10c3f4527e6312f
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,107 @@ | ||
# Speed up your Coder templates and workspaces | ||
|
||
October 31, 2024 | ||
|
||
--- | ||
|
||
If it takes your workspace a long time to start, find out why and make some changes to your Coder templates to help speed things up. | ||
|
||
## Monitoring | ||
|
||
You can monitor [Coder logs](../../admin/monitoring/logs.md) through the system-native tools on your deployment platform, or stream logs to tools like Splunk, Datadog, Grafana Loki, and others. | ||
|
||
### Coder Observability Chart | ||
|
||
Use the [Observability Helm chart](https://github.com/coder/observability) for a pre-built set of monitoring integrations. | ||
|
||
With the Observability Helm chart, you can monitor [which specific startup metrics are a part of the Helm chart?] | ||
|
||
To install it with Helm: | ||
|
||
```shell | ||
helm repo add coder-observability https://helm.coder.com/observability | ||
helm upgrade --install coder-observability coder-observability/coder-observability --version 0.1.1 --namespace coder-observability --create-namespace | ||
``` | ||
EdwardAngert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Enable Prometheus metrics for Coder | ||
|
||
Our observability bundle gives you this for free which is nice and has instructions on how to do it with Coder | ||
|
||
[Prometheus.io](https://prometheus.io/docs/introduction/overview/#what-is-prometheus) is included as part of the [observability chart](#coder-observability-chart).It offers a variety of [available metrics](../../admin/integrations/prometheus.md#available-metrics). | ||
|
||
You can [install it separately](https://prometheus.io/docs/prometheus/latest/getting_started/) if you prefer. | ||
|
||
### Workspace build timeline | ||
|
||
Use the **Build timeline** to monitor the time it takes to start specific workspaces. Identify long scripts, resources, and other things you can potentially optimize within the template. | ||
|
||
 | ||
|
||
Adjust this request to match your Coder access URL and workspace: | ||
|
||
```shell | ||
curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild}/timings \ | ||
EdwardAngert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
-H 'Accept: application/json' \ | ||
-H 'Coder-Session-Token: API_KEY' | ||
``` | ||
|
||
Visit the [API documentation](../../reference/api/builds.md#get-workspace-build-timings-by-id) for more information. | ||
|
||
## Provisioners | ||
|
||
`coder server` defaults to three provisioner daemons. Each provisioner daemon can handle one single job, such as start, stop, or delete at a time and can be resource intensive. When all provisioners are busy, workspaces enter a "pending" state until a provisioner becomes available. | ||
|
||
### Increase provisioner daemons | ||
|
||
Provisioners are queue-based to reduce unpredictable load to the Coder server. However, they can be scaled up to allow more concurrent provisioners. You risk overloading the central Coder server if you use too many local provisioners, so we recommend a maximum of five provisioners. For more than five provisioners, we recommend that you move to [external provisioners](../../admin/provisioners.md). | ||
|
||
If you can’t move to external provisioners, use the `provisioner-daemons` flag to increase the number of provisioner daemons to five: | ||
|
||
```shell | ||
coder server --provisioner-daemons=5 | ||
``` | ||
|
||
Visit the [CLI documentation](../../reference/cli/server.md#--provisioner-daemons) for more information about increasing provisioner daemons and other options. | ||
|
||
### Adjust provisioner CPU/memory | ||
|
||
We recommend that you deploy Coder to its own respective Kubernetes cluster, separate from production applications. Keep in mind that Coder runs development workloads, so the cluster should be deployed as such, without production-level configurations. | ||
|
||
Adjust the CPU and memory values as shown in [Helm provisioner values.yaml](https://github.com/coder/coder/blob/main/helm/provisioner/values.yaml#L134-L141): | ||
|
||
```yaml | ||
… | ||
resources: | ||
{} | ||
# limits: | ||
# cpu: 2000m | ||
# memory: 4096Mi | ||
# requests: | ||
# cpu: 2000m | ||
# memory: 4096Mi | ||
EdwardAngert marked this conversation as resolved.
Show resolved
Hide resolved
bpmct marked this conversation as resolved.
Show resolved
Hide resolved
|
||
… | ||
``` | ||
|
||
Visit the [validated architecture documentation](../../admin/infrastructure/validated-architectures/index.md#workspace-nodes) for more information. | ||
|
||
## Set up Terraform Provider Caching | ||
|
||
Use `terraform init` to cache providers: | ||
EdwardAngert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Pull the templates to your local device: | ||
|
||
```shell | ||
coder templates pull | ||
``` | ||
|
||
Run `terraform init` to initialize the directory: | ||
|
||
```shell | ||
terraform init | ||
``` | ||
|
||
Push the templates back to your Coder deployment: | ||
|
||
```shell | ||
coder templates push | ||
``` |
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.