Skip to content

feat(relay): make hosted capacity and abuse controls configurable and observable #114

Closed

Description

@abruption

Problem

The hosted relay now permits verified public signup without a user-count cap, but its runtime limits and operator visibility are still fixed alpha-era values.

Current main evidence:

  • session_peer_relay/relay.py hard-codes 20 handshakes per second, 100 pending session cookies, 10 global WebSocket connections, 8 connections per user, 4 per device and 32 MiB forwarded per connection.
  • control/src/server/app.ts keeps the authenticated relay API's 60 requests/minute buckets in a process-local Map that never removes inactive user keys.
  • The operator metrics expose registered users, signup state, devices, operations and state revision, but not active/waiting connections, admission pressure, rate/capacity rejection or forwarded traffic.
  • The current production unit has a 256 MiB memory limit and 256 file descriptors, so fixed application limits must remain below measured host limits and visible to the operator.

This does not call for reinstating a signup or invitation cap. It makes the service's bounded capacity explicit, observable and safe to tune as usage changes.

Proposed behavior

  • Preserve the current limits as defaults, but expose validated configuration for handshake rate, pending sessions, global/user/device connections and per-connection byte budget.
  • Reject invalid, zero, unsafe or internally inconsistent settings at startup.
  • Bound and prune expired control API rate buckets. A restart may reset a process-local authenticated-user window, but memory use must not grow with every user ever seen.
  • Keep overload semantics distinct: rate excess returns 429 and connection/session capacity returns 503 without consuming admission state incorrectly.
  • Add privacy-preserving operator metrics for current active and waiting connections, session/admission counts, rate/capacity rejection counts, forwarded frames/bytes, uptime and configured capacity. Do not expose user IDs, rooms, principals, tickets, proofs, tokens, addresses or message contents.
  • Route these aggregates through the existing Authelia-protected operator boundary. Do not add a publicly routed metrics endpoint.
  • Document an initial sizing procedure and explain that configured limits are safety bounds rather than a user-count guarantee.

Acceptance criteria

  • Existing defaults remain compatible unless an operator explicitly changes them.
  • Configuration parsing has lower/upper bounds and fail-closed tests.
  • Rate-limit state is bounded and expiry cleanup is covered with a fake clock or deterministic fixture.
  • Tests cover global, per-user and per-device saturation, waiting-room cleanup, byte-budget closure, restart behavior and 429/503 distinction.
  • Operator metrics show aggregate live capacity and rejection/traffic counters without identifiers or secrets.
  • A bounded load test exercises normal operation, saturation and recovery without real OAuth, production credentials or model calls.
  • Generic and KR deployment docs list the configured limits and their relationship to systemd memory/task/fd limits.

Non-goals

  • Limiting public signup to a fixed number of users.
  • Claiming support for 1,000 or 2,000 concurrent connections without a separate measured capacity result.
  • Moving the relay to Cloudflare or another infrastructure provider.
  • Adding message, account or device telemetry to the public CLI.

This belongs in v1.0.0-beta, alongside #110 and #111, because the service limits and operator signals should be stable before the v1 compatibility freeze.

Activity

  1. added this to the v1.0.0-beta milestone on Sep 21, 2026
  2. added
    enhancement
    on Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions