Skip to content

[scale] Replace 2s HTTP polling with Supabase Realtime for live phones #28

Description

@MrTig-afk

Problem. Patron phones poll every 2s (SessionParticipant/Lobby POLL_MS=2000, RoundOrigin active-count 2s). At ~1000 concurrent users that is ~500 DB-touching req/s, sustained. On Vercel serverless the asyncpg pool (api/db.py max_size=5) is per-λ-instance, so concurrency multiplies connections into a single small Neon Postgres — this is the real first scaling wall (before missing indexes bite).

Fix. Supabase Realtime broadcast is already the planned transport (useSessionChannel exists, hook is wired in both participant + origin views). Drive view updates from broadcast events and demote the HTTP poll to a slow safety net (~10–15s) instead of 2s. Cuts sustained QPS ~10–50×.

Note. Polling is the dominant lever; fixing this makes the index question largely moot at launch scale.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions