Compare to [Proximity Service], data is more dynamic.
High-level design

Workflow

Each client maintains a persistent conn to one of the WebSocket servers, which will forward the updated info. WebSocket connections handler for each active friend subscribes to the Pub/Sub.
Stateful, must be taken when removing existing nodes. Mark a node as “draining” at LB, so that no new conns will be routed to it. Once all existing conns are closed, the server can be removed.


Register a callback on a mobile client whenever a new friend is added, which sends messages to WebSocket Servers to subscribe to the new friend’s Pub/Sub channel.
Erlang is a general programming language and runtime environment built for highly distributed and concurrent applications. It has Lightweight processes and is easy to distribute among many Erlang servers. We can implement the WebSocket service in Erlang and replace the cluster of Redis Pub/Sub with a distributed Erlang application. Subscription is native in Erlang/OTP.