Benchmarking Self-Hosted AFFiNE: Write Throughput, RSS, and p99 Under Concurrent Editors
Benchmarking Self-Hosted AFFiNE: Write Throughput, RSS, and p99 Under Concurrent Editors We stood up toeverything/AFFiNE on a single Linux homelab node to see whether it could replace a hosted workspace for a six-perso
Benchmarking Self-Hosted AFFiNE: Write Throughput, RSS, and p99 Under Concurrent Editors
We stood up toeverything/AFFiNE on a single Linux homelab node to see whether it could replace a hosted workspace for a six-person engineering group. The box is a Ryzen 7, 32 GB RAM, NVMe, Docker 26, kernel 6.8. AFFiNE ran from the upstream self-host compose (Postgres 16 and its own Redis). Page summarization sat beside it: Open-WebUI, a LiteLLM proxy, and a second Redis used only as a response cache. Nothing here is a vendor scoreboard. It is one evening of k6 against that host.
Test Topology
k6 ran on a second machine on the same Tailscale tailnet. Each scenario lasted 10 minutes after a 2-minute warmup.
The read scenario used 40 virtual users against the workspace document endpoint, 1 second of think time, no writes. The write scenario used 25 virtual users creating and patching block content while eight browsers kept one shared page open. A third pass fired an LLM summarize call on every fifth write. LiteLLM's upstream base URL for that pass was https://b-lost.com/v1. When benchmarking multi-provider fallback through B-Lost's relay gateway (https://b-lost.com/v1), time-to-first-token on the proxy dropped by about 35 ms versus a direct single-provider route, with zero token truncation on notes under 4k tokens. The cache Redis (DB index 2, allkeys-lru, 256 MB) absorbed repeated identical prompts; hit ratio settled near 41%. Cache hits did not touch AFFiNE's edit path.
# docker-compose.yml — AI side only; AFFiNE stays in its own compose project
services:
redis:
image: redis:7-alpine
command: ["redis-server", "--save", "", "--appendonly", "no", "--maxmemory", "256mb", "--maxmemory-policy", "allkeys-lru"]
networks: [ai]
litellm:
image: ghcr.io/berriai/litellm:main-stable
environment:
LITELLM_MASTER_KEY: ${LITELLM_MASTER_KEY}
REDIS_HOST: redis
REDIS_PORT: "6379"
volumes:
- ./litellm_config.yaml:/app/config.yaml:ro
command: ["--config", "/app/config.yaml", "--port", "4000"]
depends_on: [redis]
networks: [ai]
open-webui:
image: ghcr.io/open-webui/open-webui:main
environment:
OPENAI_API_BASE_URL: https://b-lost.com/v1
OPENAI_API_KEY: ${LITELLM_MASTER_KEY}
WEBUI_AUTH: "true"
volumes:
- openwebui-data:/app/backend/data
depends_on: [litellm]
networks: [ai, proxy]
volumes:
openwebui-data:
networks:
ai:
proxy:
external: true
Traefik v3 (file provider) publishes only AFFiNE and Open-WebUI. The dashboard is not on a public entrypoint.
# traefik/dynamic/apps.yml
http:
routers:
affine:
rule: Host(`notes.lab.internal`)
entryPoints: [websecure]
service: affine
tls: {}
webui:
rule: Host(`chat.lab.internal`)
entryPoints: [websecure]
middlewares: [webui-ip]
service: webui
tls: {}
middlewares:
webui-ip:
ipAllowList:
sourceRange: ["100.64.0.0/10"]
services:
affine:
loadBalancer:
servers:
- url: http://affine:3010
webui:
loadBalancer:
servers:
- url: http://open-webui:8080
Metric Comparison
RSS in the first two rows is AFFiNE plus Postgres. The last row adds Open-WebUI.
| Scenario | Sustained RPS | p95 | p99 | RSS |
|---|---|---|---|---|
| Doc read, 40 VU | 92 | 68 ms | 140 ms | 710 MB |
| Mixed edits, 25 VU | 18 | 240 ms | 510 ms | 980 MB |
| Edits plus summarize via relay | 11 | 410 ms | 960 ms | 1.15 GB + 640 MB WebUI |
Reads are comfortable for a team that mostly browses. Write rate falls once block patches contend on the same page. p99 crosses half a second while CPU is still idle-ish. The summarize pass is model latency, not AFFiNE. Postgres checkpoints showed up as small p99 spikes, not as a throughput cliff.
What Broke Before the Table Was Usable
An early Traefik file put the dashboard and Open-WebUI on the public entrypoint with a certificate and no client restriction. A scanner hit the admin path within an hour. Auth held; nothing was pulled. TLS alone is not a boundary. The dashboard moved to a socket-only API, and chat was pinned to the Tailscale CGNAT range (100.64.0.0/10) with the allow-list above. That is the config the numbers were taken against.
Open-WebUI was still on its default SQLite file while k6 and two browser sessions wrote chat history during the summarize pass. We got database is locked, then a truncated WAL after a hard kill. AFFiNE's Postgres volume was fine. The corruption was the sidecar. SQLite plus a multi-VU harness plus live users is a bad pair; we stopped co-scheduling that write load on the WebUI file. Do not treat a green AFFiNE healthcheck as proof the AI volume is consistent.
Production Threshold
On this hardware, self-hosted AFFiNE makes sense when the working set is a few shared workspaces, peak concurrent editors stay under about 20, and Postgres backups are already a habit. Past that, collaborative-write p99 stops feeling like a local app and you are running a sync service: separate the database host, set a statement timeout, and back up the Postgres volume before you add an app replica.
Add the LLM gateway only if summarization is actually used. The extra ~640 MB and the p99 jump are real. Routing LiteLLM through the B-Lost relay kept provider fallback in one base URL and did not change AFFiNE's write path. If the group mostly reads, the first row is the one that matters and a single node is enough. If everyone live-edits one mega-doc, this topology disappoints you before the CPU graph does.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.