|
| 1 | +# Speed up your Coder templates and workspaces |
| 2 | + |
| 3 | +October 31, 2024 |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +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. |
| 8 | + |
| 9 | +## Monitoring |
| 10 | + |
| 11 | +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. |
| 12 | + |
| 13 | +### Coder Observability Chart |
| 14 | + |
| 15 | +Use the [Observability Helm chart](https://github.com/coder/observability) for a pre-built set of monitoring integrations. |
| 16 | + |
| 17 | +With the Observability Helm chart, you can monitor [which specific startup metrics are a part of the Helm chart?] |
| 18 | + |
| 19 | +To install it with Helm: |
| 20 | + |
| 21 | +```shell |
| 22 | +helm repo add coder-observability https://helm.coder.com/observability |
| 23 | +helm upgrade --install coder-observability coder-observability/coder-observability --version 0.1.1 --namespace coder-observability --create-namespace |
| 24 | +``` |
| 25 | + |
| 26 | +### Enable Prometheus metrics for Coder |
| 27 | + |
| 28 | +Our observability bundle gives you this for free which is nice and has instructions on how to do it with Coder |
| 29 | + |
| 30 | +[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). |
| 31 | + |
| 32 | +You can [install it separately](https://prometheus.io/docs/prometheus/latest/getting_started/) if you prefer. |
| 33 | + |
| 34 | +### Workspace build timeline |
| 35 | + |
| 36 | +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. |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +Adjust this request to match your Coder access URL and workspace: |
| 41 | + |
| 42 | +```shell |
| 43 | +curl -X GET http://coder-server:8080/api/v2/workspacebuilds/{workspacebuild}/timings \ |
| 44 | + -H 'Accept: application/json' \ |
| 45 | + -H 'Coder-Session-Token: API_KEY' |
| 46 | +``` |
| 47 | + |
| 48 | +Visit the [API documentation](../../reference/api/builds.md#get-workspace-build-timings-by-id) for more information. |
| 49 | + |
| 50 | +## Provisioners |
| 51 | + |
| 52 | +`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. |
| 53 | + |
| 54 | +### Increase provisioner daemons |
| 55 | + |
| 56 | +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). |
| 57 | + |
| 58 | +If you can’t move to external provisioners, use the `provisioner-daemons` flag to increase the number of provisioner daemons to five: |
| 59 | + |
| 60 | +```shell |
| 61 | +coder server --provisioner-daemons=5 |
| 62 | +``` |
| 63 | + |
| 64 | +Visit the [CLI documentation](../../reference/cli/server.md#--provisioner-daemons) for more information about increasing provisioner daemons and other options. |
| 65 | + |
| 66 | +### Adjust provisioner CPU/memory |
| 67 | + |
| 68 | +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. |
| 69 | + |
| 70 | +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): |
| 71 | + |
| 72 | +```yaml |
| 73 | +… |
| 74 | + resources: |
| 75 | + {} |
| 76 | + # limits: |
| 77 | + # cpu: 2000m |
| 78 | + # memory: 4096Mi |
| 79 | + # requests: |
| 80 | + # cpu: 2000m |
| 81 | + # memory: 4096Mi |
| 82 | +… |
| 83 | +``` |
| 84 | + |
| 85 | +Visit the [validated architecture documentation](../../admin/infrastructure/validated-architectures/index.md#workspace-nodes) for more information. |
| 86 | + |
| 87 | +## Set up Terraform Provider Caching |
| 88 | + |
| 89 | +Use `terraform init` to cache providers: |
| 90 | + |
| 91 | +Pull the templates to your local device: |
| 92 | + |
| 93 | +```shell |
| 94 | +coder templates pull |
| 95 | +``` |
| 96 | + |
| 97 | +Run `terraform init` to initialize the directory: |
| 98 | + |
| 99 | +```shell |
| 100 | +terraform init |
| 101 | +``` |
| 102 | + |
| 103 | +Push the templates back to your Coder deployment: |
| 104 | + |
| 105 | +```shell |
| 106 | +coder templates push |
| 107 | +``` |
0 commit comments