Fan-out

Fan-out is the WebSocket delivery pattern where one broadcast published to a channel is sent to every subscriber of that channel. One publish in, N deliveries out. The N is the fan-out factor for that broadcast.

Why it matters

Fan-out is the work pattern that defines modern real-time apps. Notifications, presence indicators, typing dots, live cursors, leaderboards, collaborative editing: all of them are broadcast-once, deliver-to-many. As subscriber counts grow, the fan-out factor grows linearly. A channel with ten subscribers fans out to ten clients per broadcast. A channel with ten thousand subscribers fans out to ten thousand.

The fan-out factor is not under the publisher's control. The publisher emits one broadcast. The service decides how many subscribers exist and delivers accordingly. This matters because pricing models that bill per delivered copy attach the cost of growth to a dimension the engineer cannot directly cap. Pricing models that bill per broadcast attach cost to the dimension the engineer can control (publish rate).

How it works

A subscriber opens a WebSocket connection to the real-time service and sends a pusher:subscribe frame naming a channel. The service registers the connection against that channel's subscriber set. When a publisher sends a broadcast to the channel, the service iterates the subscriber set and pushes a copy of the event frame to each one over its existing connection.

The fan-out is server-side. The client never sees N. From the publisher's perspective the work is a single HTTP POST or single WebSocket frame. From the service's perspective it is N socket writes, where N is the live subscriber count at the instant of broadcast.

Quick example. A typing-indicator broadcast on a channel with 200 subscribers produces:

  • 1 broadcast from the publisher
  • 200 fan-out deliveries from the service
  • 200 inbound frames at clients

The same broadcast on a channel with 2 subscribers produces 2 deliveries. The publisher code is identical. Only the live subscriber count changed.

Related terms

  • Broadcast is the unit the publisher hands off. Fan-out is what happens to it.
  • Fan-out tax is the per-subscriber-multiplier billing model some services attach to fan-out.
  • Concurrent connections is the gauge that determines the maximum possible fan-out factor.

See also

What is fan-out in WebSockets?
Fan-out is the delivery pattern where a single broadcast published to a channel is sent to every subscriber currently connected to that channel. One publish, N deliveries. The N is the fan-out factor.
Is fan-out the same as a broadcast?
No. A broadcast is the unit of work the publisher hands off. Fan-out is the per-subscriber delivery the service performs underneath. One broadcast can fan out to one subscriber or one million, depending on channel size.
Why does fan-out matter for pricing?
Some real-time services bill per delivered copy (per fan-out), others bill per broadcast (flat). The same workload can produce wildly different bills depending on which model the service uses.