Skip to the content.

Real time interactions on live video

This note is based on a InfoQ talk about Streaming a Million Likes/Second: Real-Time Interactions on Live Video from Linkedin.

Traditional way to stream likes

The persistent connection is using HTTP Long Poll with “Server Sent Events”.

// Client lib
var evtSource = new EventSource("https://www.linkedin.com/realtime/connect");
evtSource.onmessage = function(e) {
  var likeObj = JSON.parse(e.data);
}

workflow-1 workflow-2 workflow-3

Challenges

Tons of connections

multi-devices-challenge

Linkedin uses Akka and Play framework for connection management.

connection-mgmt-1 connection-mgmt-2 connection-mgmt-3 connection-mgmt-4 client-sees-likes

Subscriptions

We could not blindly broadcast the likes to all clients, because different users are watching different live videos.

viewers-sub state-after-sub

Scale to 10K or more viewers

scale-dispatch-1 scale-dispatch-2 scale-dispatch-3 scale-dispatch-4

Dispatcher is the bottleneck

How to handle the 1000 likes per second?

dispatcher-bottleneck-1

Multi data centers

We don’t have subscribers for red-video from DC-1 and DC-2, but there are only subscribers from DC-3.

multi-datacenter-1

Cross data center subscriptions

live-video-red: dc-3-front-1
live-video-green: dc-2-front-1
live-video-green: dc-1-front-1
...

Few points to keep in mind:

Publish likes to all data centers

publish-to-all-dc-1 publish-to-all-dc-2 publish-to-all-dc-3

Few points to keep in mind:

References