Phoenix.PubSub is probably the most important component in @elixirphoenix@elixirlang .
We will benefit a lot by understanding the internals of Phoenix.PubSub.
* a :pg server is started with the scope name: Pheonix.PubSub
* a pubsub supervisor supervises a registry and an adapter server
* the adapter server joins a :pg group during initialization
The adapter server is also the PubSub shard, they exist to broker broadcasts across the cluster, and relay those messages to local node subscribers which are recorded in the ETS table in the registry.
This is how it looks like in a two nodes cluster:
How does broadcast work?
* The adapter will ask the :pg server about information of remote nodes in the cluster. It will send one message to the remote adapter
* send message to local subscribers
* when the remote adapter gets the message, it will dispatch it to its local nodes.