Skip to content

Commit 285646b

Browse files
ammariomatifali
andauthored
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>
1 parent d3356fa commit 285646b

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

docs/templates/agent-metadata.md

+24-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ resource "coder_agent" "main" {
7070
distributions and provides virtual memory, CPU and IO statistics. Running `top`
7171
produces output that looks like:
7272

73-
```
73+
```text
7474
%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
7575
MiB Mem : 16009.0 total, 493.7 free, 4624.8 used, 10890.5 buff/cache
7676
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
8080
distributions and provides virtual memory, CPU and IO statistics. Running `vmstat`
8181
produces output that looks like:
8282

83-
```
83+
```text
8484
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
8585
r b swpd free buff cache si so bi bo in cs us sy id wa st
8686
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
9191
most package managers under the name `dstat`. The output of running `dstat 1 1` looks
9292
like:
9393

94-
```
94+
```text
9595
--total-cpu-usage-- -dsk/total- -net/total- ---paging-- ---system--
9696
usr sys idl wai stl| read writ| recv send| in out | int csw
9797
1 1 98 0 0|3422k 25M| 0 0 | 153k 904k| 123k 174k
9898
```
99+
100+
## DB Write Load
101+
102+
Agent metadata can generate a significant write load and overwhelm your
103+
database if you're not careful. The approximate writes per second can be
104+
calculated using the formula:
105+
106+
```text
107+
(metadata_count * num_running_agents * 2) / metadata_avg_interval
108+
```
109+
110+
For example, let's say you have
111+
112+
- 10 running agents
113+
- each with 6 metadata snippets
114+
- with an average interval of 4 seconds
115+
116+
You can expect `(10 * 6 * 2) / 4` or 30 writes per second.
117+
118+
One of the writes is to the `UNLOGGED` `workspace_agent_metadata` table and
119+
the other to the `NOTIFY` query that enables live stats streaming in the UI.

0 commit comments

Comments
 (0)