Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/docs/content/docs/en/agent.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ The agent collects the following metrics (sourced from the `sysinfo` library, `/

## Resource Footprint

The Agent has negligible CPU cost (<1%) and a steady-state memory footprint in the tens of MB. For the full measured Agent and Server CPU/memory/disk/network data, see [Resource Usage](/en/docs/resource-usage).
In `v1.0.0-beta.7` Linux benchmarks, the static musl Agent uses `0.14%–0.19%` of 1 vCPU at idle, `~11.1 MiB` `VmRSS` (`0.82–0.91 MiB` private `RssAnon` + `10.27 MiB` reclaimable executable pages; `2.62–2.95 MiB` warm systemd cgroup memory, or `1.21 MiB` with `[security] enabled = false`), and `~158 B/s` (`~412 MB/month`) of network bandwidth. For full hardware requirements, stress tests, cgroup limits, and Server observations, see [Resource Usage](/en/docs/resource-usage).

<Cards>
<Card title="Server Setup" href="/en/docs/server" />
Expand Down
77 changes: 60 additions & 17 deletions apps/docs/content/docs/en/resource-usage.mdx
Original file line number Diff line number Diff line change
@@ -1,32 +1,76 @@
---
title: Resource Usage
description: Historical CPU, memory, disk, and network observations for the ServerBee Agent and Server.
description: Measured CPU, memory, disk, network, and hardware requirements for the ServerBee Agent, plus historical Server observations.
icon: Gauge
---

This page preserves historical resource observations for the ServerBee **Agent** and **Server**. They are not benchmarks of the current release. For database growth estimates, see [Storage & Capacity Planning](/en/docs/storage-sizing).
This page documents measured resource requirements and runtime performance for the ServerBee **Agent** (`v1.0.0-beta.7`), alongside preserved historical observations for the **Server** and earlier releases. For SQLite database growth estimates, see [Storage & Capacity Planning](/en/docs/storage-sizing).

## Agent

### Minimum vs Recommended Requirements

Based on controlled Linux VM benchmarks of `serverbee-agent` `v1.0.0-beta.7` (statically linked musl binary, server-dictated 3-second reporting interval, default capabilities). For full scenario tables, stress tests, and methodology, see the [Agent benchmark report](https://github.com/ZingerLittleBee/ServerBee/blob/main/docs/research/2026-11-24-agent-resource-benchmark.md).

| Resource | Absolute floor (minimal config) | Minimum viable (default config) | Recommended (production / active use) | Notes |
|----------|---------------------------------|---------------------------------|---------------------------------------|-------|
| **CPU** | 1 vCPU (`CPUQuota=5%`) | 1 vCPU (shared / burstable) | 1+ vCPU | Steady-state uses `0.14%–0.19%` of 1 core; `0` CPU throttles down to `CPUQuota=5%` |
| **Available RAM (Agent budget)** | **16 MiB** (`[security] enabled = false`, no swap) | **32 MiB** (cold boot + default `security_events`) | **64 MiB** (**128 MiB** with Web Terminal or `>500` procs) | Cold-cache default peaks at `21.0 MiB` cgroup (`0` reclaim stalls at `16 MiB`, `0` pressure at `24 MiB`) |
| **Host VPS total RAM** | 64–128 MiB Linux VPS | 128–256 MiB Linux VPS | 512 MiB+ Linux VPS | Agent uses `<2%–5%` of a 512 MiB VPS; host kernel and init dominate total RAM |
| **Disk space** | **20 MiB** | **30 MiB** | **50–100 MiB** | Binary is `13.36 MiB` (`amd64`) / `12.10 MiB` (`arm64`); total install is `13.53 MiB`. Reserve `2×` binary size for self-upgrade `.bak` rollback |
| **Network bandwidth** | **2 Kbps** (`~0.45 GB/mo`) | **5 Kbps** (`~0.5 GB/mo`) | **100 Kbps+** (Web Terminal / File Manager) | Measured idle steady-state: `158 B/s` TX + `0.8 B/s` RX (`~412 MB/month`) |
| **OS & libc** | Linux with `/proc` (no `glibc` required) | Linux + systemd or OpenRC | Linux 5.x/6.x with `systemd` (`cgroup v2`) | Official Linux `amd64`/`arm64` binaries are statically linked musl (`not a dynamic executable`) |
| **Open FDs (`nofile`)** | `>= 256` (`<150` host procs) | `>= 1024` (default `ulimit -n`) | **`>= 4096`–`65536`** (`>500` host procs) | `sysinfo` keeps persistent `/proc/<pid>/stat` FDs (~1:1 with host processes); set `LimitNOFILE=65536` on dense hosts |

### Measured Performance (`v1.0.0-beta.7`)

<Callout type="info">
Source: the measurement notes originally recorded on this page for v0.9.3, dated 2026-05-19 unless noted otherwise. Raw benchmark logs and exact binary linkage were not archived with those notes. Memory/CPU readings are historical observations; the Agent network figure is a protocol-based estimate. Measure your deployed version, allocator, Agent count, enabled collectors, and query load before setting resource limits.
Measured on 2026-11-24 using official `serverbee-agent` `v1.0.0-beta.7` (`linux-amd64` static musl, `deploy/install.sh` binary mode) on Ubuntu 24.04.5 LTS (`systemd 255`, `cgroup v2`, KVM AMD EPYC) reporting every 3 seconds over WAN TLS WebSocket to a `v1.0.0-beta.7` Server.
</Callout>

## Agent
#### Steady-State Idle Soak (300s)

| Metric | 1 vCPU / 4 GiB VM | 2 vCPU / 8 GiB VM | Scope |
|--------|-------------------|-------------------|-------|
| **CPU (1-core avg / p95 / max)** | `0.144%` / `0.426%` / `0.544%` | `0.190%` / `0.568%` / `0.791%` | Cgroup v2 `cpu.stat` (`0.143%` / `0.190%` via `/proc`) |
| **Agent `VmRSS` (`RssAnon` + `RssFile`)** | `11.09 MiB` (`0.82` + `10.27 MiB`) | `11.18 MiB` (`0.91` + `10.27 MiB`) | Process resident memory (`PSS`: `11.08` / `11.18 MiB`) |
| **Systemd cgroup memory (warm cache)** | `2.62 MiB` (max `2.75 MiB`) | `2.95 MiB` (max `3.19 MiB`) | Includes `journalctl -f` child; drops **54%** to `1.21 MiB` when `[security] enabled = false` |
| **Systemd cgroup memory (cold cache)** | `19.0 MiB` (peak `21.0 MiB`) | — | After `drop_caches=3` with `MemoryMax=24M` (includes faulted executable pages) |
| **Memory stability (300s `RssAnon` delta)** | `+12 KiB` (`+1.89 KiB/min`) | `+8 KiB` (`+0.65 KiB/min`) | Flat plateau over 100 collection cycles, zero leak |
| **Threads / Open FDs** | `3` / `46` (`43–47`) | `5` / `51` (`48–52`) | Tokio spawns 1 worker thread per vCPU |
| **Network bandwidth (exact TCP socket)** | `158.4 B/s` TX, `0.8 B/s` RX | `158.0 B/s` TX, `0.8 B/s` RX | `ss -tinp`; `~475 B` per 3s TLS frame (`~412 MB/month`) |
| **Binary / total installed disk** | `13.36 MiB` / `13.53 MiB` | `13.36 MiB` / `13.53 MiB` | `linux-amd64` static musl (`linux-arm64` binary: `12.10 MiB`) |

The original notes describe a 4-core AMD EPYC 7B13 / 8 GB / Ubuntu 24.04 (KVM) host, Agent v0.9.3, a 3-second collection interval, temperature collection enabled, and reporting to a remote Server over an HTTPS WebSocket.
#### Workload, Stress & Cgroup Floor Highlights

| Resource | Cold start (~90s) | After 8h | Scope |
|----------|-------------------|----------|-------|
| Memory (systemd cgroup) | ~4.3 MB, peak ~5.1 MB | ~27 MB, peak ~28 MB | Cgroup accounting; a different scope from process RSS |
| Memory (`ps` RSS) | ~10 MB | ~34 MB | Process resident memory, including shared mappings |
| CPU | ~0.7% (single core) | ~0.5% (single core) | Observed collection workload |
| Threads | 10 | 9–10 | Observed tokio runtime |
| Binary size | ~11 MB | — | Historical linux-amd64 binary |
| Network | Estimated ≤ 1–2 KB/s | — | One `SystemReport` JSON per 3-second interval plus ping/pong; varies with metrics |
- **Startup & enrollment:** Cold-start enrollment over trans-Pacific WAN completed in `1.26 s` (`~25 ms` local agent work; remainder was WAN RTT/TLS). Warm `systemctl restart` reconnected in `0.93 s`.
- **Active dashboard viewing:** Zero measurable extra agent CPU, memory, or network cost — the Server fans out already-received telemetry to browsers.
- **Active Web Terminal (PTY):** Adds `+1` thread, `+2.39 MiB` cgroup memory (interactive shell child; agent `RssAnon` rose by `+7 KiB`), `0.44%` avg cgroup CPU (`3.47%` max), and `971 B/s` TX during periodic command output.
- **Host CPU & I/O stress:** Under 100% host CPU saturation, telemetry remained uninterrupted (`0.175%` agent CPU). Heavy disk fsync loops plus 200 active local TCP sockets added only `+0.026%` CPU and `+83 KiB` cgroup memory.
- **High process count (`>500` processes):** Spawning 500 sleeping processes (`519` total) scaled open FDs ~1:1 (`51 → 545`), tripled CPU (`0.19% → 0.57%` avg, `3.00%` max), and increased cgroup memory `2.3×` (`2.95 → 6.80 MiB`) because `sysinfo` keeps persistent `/proc/<pid>/stat` FDs to count processes.
- **Offline & reconnect recovery:** During a 40s packet blackhole, memory and FDs stayed flat with zero restarts; after the half-open TCP socket closed, reconnection to `Sent SystemInfo` took `1.36 s`.
- **Hard cgroup v2 floors (1 vCPU, `MemorySwapMax=0`):**
- Warm-cache OOM boundary (with 300-process burst): survives `6 MiB` (default) / `4 MiB` (`security.enabled = false`), OOMs at `4 MiB` / `3 MiB`.
- Cold-cache zero-thrash floor (`drop_caches=3`, default): **`16 MiB`** (`0` reclaim stalls, `0` OOM); **`24 MiB`** has zero reclaim pressure. Setting `MemoryMax` below `16 MiB` avoids OOM down to `6 MiB` but causes heavy executable code-page thrashing (`>137k` reclaim stalls in 20s).
- `CPUQuota` floor: `0` throttles down to **`5%`** (`2%` still keeps telemetry flowing with `59 ms` throttled over 45s).

Memory increased during the eight-hour observation. Those readings alone do not establish a long-term plateau or distinguish allocator retention from a leak. The recorded host OS does not establish which libc the binary used.
### Low-Resource VPS & Dense-Host Tuning

- **Low-RAM VPS (`<= 256 MiB` RAM):** Use the static binary (`deploy/install.sh`) rather than Docker. If you do not need SSH journal security watching, set `[security] enabled = false` in `/opt/serverbee/etc/agent.toml` to eliminate the `journalctl -f` child process and cut steady-state cgroup memory by ~54% (`1.21 MiB` warm). Keep unused capabilities (`terminal`, `exec`, `file`, `docker`) disabled. Safe systemd guardrails are `MemoryMax=64M` and `CPUQuota=15%` (use `MemoryMax=32M` only without `terminal`/`exec` and below `300` processes; do not go below `24M` with default config).
- **Dense hosts (`>500` processes / containers):** Add a systemd drop-in with `LimitNOFILE=65536` and `MemoryMax=128M` (or leave memory uncapped) so `sysinfo`'s `/proc` descriptors do not hit the default `1024` open-file limit.

### Historical `v0.9.3` Agent Observation

<Callout type="info">
Preserved for historical reference: earlier notes for `v0.9.3` (dated 2026-05-19, 4-core AMD EPYC 7B13 / 8 GB / Ubuntu 24.04 KVM, 3s interval, raw logs and exact linkage unarchived) recorded `~10 MB` → `~34 MB` `ps` RSS (`~4.3 MB` → `~27 MB` systemd cgroup) over 8 hours, `~0.5%–0.7%` CPU, `9–10` threads, an `~11 MB` binary, and a protocol-based network estimate of `<= 1–2 KB/s`. That 8-hour reading alone did not establish a long-term plateau or libc linkage; use the `v1.0.0-beta.7` measurements above for current deployments.
</Callout>

## Server

<Callout type="info">
Source: the historical measurement notes originally recorded on this page for v0.9.3, dated 2026-05-19 unless noted otherwise. Raw benchmark logs and exact binary linkage were not archived with those notes. Measure your deployed version, allocator, Agent count, enabled collectors, and query load before setting Server resource limits.
</Callout>

### Historical Railway observation

The original page recorded roughly 140–170 MB with a small number of Agents and `MALLOC_ARENA_MAX=2` present in the environment. It also reported 800 MB–1 GB after 2–3 days in another run. The notes do not capture exact build linkage, Agent count, query load, or a controlled comparison. These are historical readings, not evidence that the environment variable caused the difference or a memory target for the current release.
Expand Down Expand Up @@ -55,9 +99,8 @@ Server disk use includes SQLite, uploaded brand images, downloaded GeoIP/ASN MMD
## Caveats

- The historical idle Server readings do not describe many Agents or heavy query load.
- Cgroup memory and process RSS measure different scopes; compare like with like.
- Agent network usage is an estimate, not a captured traffic benchmark.
- A steady eight-hour reading does not prove long-term stability. Investigate unexplained growth with workload and allocator context.
- Cgroup memory (`memory.current`) and process RSS (`VmRSS` / `PSS`) measure different scopes; compare like with like and account for warm vs cold page cache when setting `MemoryMax`.
- A 5-minute soak confirms flat steady-state behavior for the Agent reporting loop, but hosts running additional capabilities (Docker monitoring, frequent remote commands, or high process churn) should still validate limits under their real workload.

## Related Docs

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/zh/agent.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ Agent 采集以下指标(来源于 `sysinfo` 库、Linux 下的 `/proc`,以

## 资源开销

Agent CPU 开销可忽略(&lt;1%),内存稳态在数十 MB 级别。完整的 Agent 与 Server CPU/内存/磁盘/网络实测数据见[资源开销](/zh/docs/resource-usage)。
在 `v1.0.0-beta.7` Linux 实测中,静态 musl Agent 空载稳态占用单核 `0.14%–0.19%` CPU、`~11.1 MiB` `VmRSS`(私有 `RssAnon` 仅 `0.82–0.91 MiB`,其余 `10.27 MiB` 为可回收可执行文件代码页;热缓存 systemd cgroup 内存 `2.62–2.95 MiB`,关闭 `[security] enabled = false` 后为 `1.21 MiB`)以及约 `158 B/s`(约 `412 MB/月`)网络带宽。完整的硬件要求、压测结果、cgroup 下限与 Server 观测数据见[资源开销](/zh/docs/resource-usage)。

<Cards>
<Card title="Server 安装配置" href="/zh/docs/server" />
Expand Down
Loading
Loading