docs: disclaim write load for agent metadata (#7048)

* docs: disclaim write load for agent metadata

* Update docs/templates/agent-metadata.md

Co-authored-by: Muhammad Atif Ali <atif@coder.com>

* Update docs/templates/agent-metadata.md

Co-authored-by: Muhammad Atif Ali <atif@coder.com>

---------

Co-authored-by: Muhammad Atif Ali <atif@coder.com>
This commit is contained in:
Ammar Bandukwala
2023-04-16 00:46:04 -05:00
committed by GitHub
parent d3356fa48e
commit 285646bf24

View File

@ -70,7 +70,7 @@ resource "coder_agent" "main" {
distributions and provides virtual memory, CPU and IO statistics. Running `top`
produces output that looks like:
```
```text
%Cpu(s): 65.8 us, 4.4 sy, 0.0 ni, 29.3 id, 0.3 wa, 0.0 hi, 0.2 si, 0.0 st
MiB Mem : 16009.0 total, 493.7 free, 4624.8 used, 10890.5 buff/cache
MiB Swap: 0.0 total, 0.0 free, 0.0 used. 11021.3 avail Mem
@ -80,7 +80,7 @@ MiB Swap: 0.0 total, 0.0 free, 0.0 used. 11021.3 avail Mem
distributions and provides virtual memory, CPU and IO statistics. Running `vmstat`
produces output that looks like:
```
```text
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 19580 4781680 12133692 217646944 0 2 4 32 1 0 1 1 98 0 0
@ -91,8 +91,29 @@ than `vmstat` but often not included in base images. It is easily installed by
most package managers under the name `dstat`. The output of running `dstat 1 1` looks
like:
```
```text
--total-cpu-usage-- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai stl| read writ| recv send| in out | int csw
1 1 98 0 0|3422k 25M| 0 0 | 153k 904k| 123k 174k
```
## DB Write Load
Agent metadata can generate a significant write load and overwhelm your
database if you're not careful. The approximate writes per second can be
calculated using the formula:
```text
(metadata_count * num_running_agents * 2) / metadata_avg_interval
```
For example, let's say you have
- 10 running agents
- each with 6 metadata snippets
- with an average interval of 4 seconds
You can expect `(10 * 6 * 2) / 4` or 30 writes per second.
One of the writes is to the `UNLOGGED` `workspace_agent_metadata` table and
the other to the `NOTIFY` query that enables live stats streaming in the UI.