Thanks for reading systemdesign.one newsletter. If you're not yet subscribed, let me help you with that:
High-Level Design
The Live Comment service carries out the following operations at a high level:
The gateway server distributes live comments to the clients via server-sent events (SSE)
Clients subscribe to a live video on the gateway server using Hypertext Transfer Protocol (HTTP)
The gateway server maintains an in-memory subscription store to keep track of viewership associations
The gateway server subscribes to a live video on the endpoint store
The endpoint store manages the list of gateway servers subscribed to a specific live video
Heartbeat signals or time to live (TTL) on keys in the subscription store can be used to handle inactive SSE connections
When a live video ends, it triggers an update in the endpoint store
The dispatcher broadcasts live comments to the dispatcher in peer data centers