Commit graph

5 commits

Author SHA1 Message Date
Johannes Millan
5f97f56487 docs(supersync): align caddy admin healthcheck note to 127.0.0.1
Comment-only follow-up to the docker-compose healthcheck fix: the Caddyfile note still said localhost:2019; align it to the literal IP the probe now uses.
2026-05-18 16:06:45 +02:00
johannesjo
25d637e917 chore(supersync): harden compose for 4GB VPS production
Right-size container limits to fit a 4GB / 2-vCore VPS host without
OOM risk, and apply minimal best-practice hardening informed by
multi-agent review.

Container memory budget (sum 2816 MB, leaves ~1.2 GB host headroom):
- postgres: 1g → 1.5g (was at 74% under 199 WSS connections)
- supersync: 1g → 768m (uses 143 MiB steady state)
- dozzle: add 64m cap (was unbounded)
- uptime-kuma: add 192m cap (was unbounded)
- caddy: unchanged at 256m

Postgres tuning (1.5g cap, shm_size 256m to allow shared_buffers > 64m):
- shared_buffers=384MB, effective_cache_size=1GB
- work_mem=4MB, maintenance_work_mem=128MB
- max_connections=40 (Prisma pool is single-digit; 40 leaves headroom
  for migrations + psql; 100 was an OOM landmine vs 1.5g cap)
- random_page_cost=1.1 (SSD)
- idle_in_transaction_session_timeout=300000 (5 min — catches leaked
  Prisma idle-in-tx but stays well above migrate-deploy.sh
  STEP_TIMEOUT=1800 for CONCURRENTLY index recovery)
- wal_compression=on, huge_pages=off

Other hardening:
- Standardize restart policy to unless-stopped across all services
- Add caddy healthcheck via admin API at localhost:2019; Caddyfile
  comment warns future edits not to disable admin
- Add ulimits.nofile=65535 to supersync (Alpine soft default 1024 is
  tight for 200+ WSS + reconnect bursts)
- Pin networks.internal.name=super-sync-server_internal so the
  monitoring overlay can attach via external: true regardless of
  COMPOSE_PROJECT_NAME
- Attach dozzle + uptime-kuma to internal network so Kuma can probe
  http://supersync:1900/health by service name

Notes for future maintenance:
- oom_score_adj was tried and removed: Compose v2 silently ignores it
  (verified on host via /proc/<pid>/oom_score_adj returning 0).
  Would need a systemd post-up hack to apply — not worth it.
- The reconnect storm that motivated this work is fixed separately
  on master in b404bf8a3.
2026-05-16 12:34:13 +02:00
Johannes Millan
db30f92e23 fix(sync-server): remove invalid timeout subdirective from Caddyfile
Caddy v2 reverse_proxy does not support a top-level `timeout`
subdirective. The response_header_timeout in the transport block
already covers long-running operations.
2026-03-23 13:05:40 +01:00
Johannes Millan
ae40f0ba2e feat(sync): add comprehensive timeout handling for large operations
Implement coordinated timeout strategy across all layers:

**Client-side (90s total):**
- HTTP requests: 75s timeout with AbortController
- Sync wait timeout: 90s (exceeds all server timeouts)
- Restore service: Retry logic for network errors (2s, 4s backoff)
- Better error messages for timeout scenarios

**Server-side:**
- Caddy proxy: 85s timeout (exceeds Fastify)
- Fastify server: 80s request timeout (exceeds DB timeout)
- Database operations: 60s (unchanged)

**Rationale:**
Each timeout layer exceeds the one below it, allowing inner operations
to complete and report errors properly. The 90s client timeout ensures
large operations (snapshot generation, imports) can complete without
premature abortion.

**Monitoring:**
- Log slow requests >30s for visibility
- Detailed error logging with duration tracking
- Android WebView timeout support via CapacitorHttp
2026-01-20 17:07:24 +01:00
Johannes Millan
ff41dcaae0 build(superSync): add docker config 2025-12-12 20:48:40 +01:00