[2.x] Realtime: rethink guest connections (connection cap, an off switch, scoped live updates)

Aperta
#5,174 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
30/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript, laravel, php

Direzione di ricerca

Read the linked issues #5154 and #5155 and trace Manager::subscribeToChannel(), Websocket::onOpen(), and the forum JavaScript check for websocket.disallow_connection. Map how guest subscriptions, connection caps, and public payloads currently work before estimating the proposed changes. Done means guest and member caps are separate, guest connections can be disabled server-side, guest updates are scoped to discussions, and realtime payloads omit the discussion posts id list.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

type/performance type/reliability

Follows on from #5154 / #5155.

Today
  • Every guest page view opens a websocket and subscribes to public.
  • public is forum-wide. Anything sent there goes to every connected guest, as the full API document rendered for a guest. For a reply that is 10–50 KB, and it grows with the thread because the discussion half lists every post id. Today only discussion events reach it (started, renamed, hidden/restored, sticky, lock, tags). Post events never did (#5154).
  • Guests count towards max-connections (default 1,000). Manager::subscribeToChannel() counts every subscribed socket, and Websocket::onOpen() refuses new connections once the cap is reached, before it knows who is connecting. So guests can fill the cap and lock members out of realtime.
  • Admins can't turn guest connections off. The forum JS checks websocket.disallow_connection, but the server never sends it.
Why it matters

The websocket server is one PHP process. It sends one uncompressed copy of each public payload to each guest connection. On forums with hundreds or thousands of connected users, putting replies, edits, likes and reactions on public (as #5155 first proposed) would multiply what it sends several times over.

Proposal
  1. Connection cap. Count guest and member connections separately, so guests can never lock members out.
  2. An off switch. A server-side setting for guest connections, sent to the forum so the existing client check works. When it's off, the server also skips rendering public payloads.
  3. Scoped live updates for guests.
    • public carries only small events (ids, the last post number), never full documents.
    • A guest reading a discussion subscribes to a channel for that discussion (e.g. public-discussion=ID) and leaves it when they navigate away. The server renders the guest payload once per event and sends it only there.
    • The index shows "new activity" from the small event, and fetches the discussions when the reader releases them.
  4. Leaner payloads for everyone. Drop the discussion's posts id list from realtime payloads. Clients re-fetch the discussion when an event arrives anyway.

Member delivery (a payload per member on their own channel) isn't part of this. The member-side visibility fix stays in #5155.

Lingua principale
PHP
Stelle
6.8k
Fork
891
Merge medio
1g 10h
PR unite (30g)
209

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di flarum/framework

Tutte le issue di flarum/framework

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.