PubSub Realtime messaging service @ Hotstar
This talk covers our journey of building an MQTT based Pubsub system for 50M concurrent socket connections, the challenges faced and the architecture that powered Hotstar’s realtime social features for IPL 2019.
The Social & Gaming Team at Hotstar built an interactive Social Feed in VIVO IPL 2019 that appears below the video on the Hotstar mobile apps.
The content in the feed comes from various source, local timer objects, Questions/Answer/Prizes/Rounds/Advertisements/Celeb handles, API calls, user initiated and for a matter of fact, anything that can be shown on the feed in real-time without any scope of caching and without draining clients’ data/battery.
PubSub is a highly scalable and durable messaging infrastructure that serves as a foundation for realtime communication with millions of concurrent users. By providing one-to-many (broadcast or fan-out) use-cases as a starting point, PubSub delivers low-latency, durable messaging from various backend services to all connected users simultaneously with minimal battery and data usage.
Piyush Gupta will talk about his journey of building PubSub Infrastructure. He will stress upon the challenges faced and learnings accrued on this journey of building a system capable of handling 50M peak concurrent connections with 1rps messages sent rate. Over the duration of VIVO IPL 2019, this service ended up sending over 250 Billion+ messages.
Jargons Used in the Talk:
Pubsub: Publish–Subscribe is a messaging pattern where senders of messages, called publishers, do not program the messages to be sent directly to specific receivers, called subscribers, but instead categorize published messages into classes without knowledge of which subscribers, if any, there may be.
Connections: (self explanatory)
- Topic: UTF-8 string that the broker uses to filter messages for each connected client
Subscriptions: (self explanatory)
Connack Latency: Time for establishing MQTT connection
Pub-to-Sub Latency: Pub-to-sub latency refers to the total time spent by a data event from its publisher to its subscriber including the time taken for broker matching.
EMQx: EMQx is an open source IoT MQTT message broker based on the Erlang/OTP platform.
EMQx Cluster: A cluster of n nodes (or instances) each running EMQ application and grouped via a ClusterName. A message sent to one node in the cluster is transmitted further to all the other nodes in the same cluster.
EMQx Bridge: For an EMQ bridge from Node#A to Node#B for topic T, it will forward all messages received on topic T from Node#A to Node#B.
AWS ELB: Elastic Load Balancer; LB as a service for HTTP/HTTPS and TCP/SSL connections
AWS ELB SurgeQueue Length: ELB has a queue for concurrently incoming requests. SurgeQueue is used to maintain a request queue of 1024 in surge traffic
AWS ELB Spillover Count: Requests that spill over the surgequeue limit is rejected by the ELB and is counted under spillover count
AWS NLB: Network Load Balancer; LB as a service especially for TCP connections.
Senior Full Stack Developer, Building Social & Gaming for Hotstar
- Lead projects involving development, architecture and deployment of cloud applications at scale