SlideShare a Scribd company logo
Realtime Content Delivery: Powering
dynamic instant experiences
Akhilesh Gupta
Realtime Engineer, LinkedIn
What is Realtime Content Delivery?
Typing Indicators
IMESSAGE
Live Hearts & Comments
PERISCOPE
FACEBOOK
Typing indicators
Timeline Comments
Realtime Driver Location
How does Uber update the
location of nearby cars?
UBER
Semi-Realtime Technology
Polling
• Empty responses are the
majority
• Frequency f of polling
• High — Unnecessary traffic
• Low — Delay in information
dissemination
Frontend
Server
t0 t1 t2 t3
f
OLD LINKEDIN MESSAGING
3:16 AM
Why did I end up in Auditorium 7?
OLD LINKEDIN MESSAGING
3:19 AM
Push notification based
Push Notifications
• Slow
• Unreliable
• Throttled by APNS/GCM
• Size constraints
APNS/GCM
Backend
Processing
AB
Realtime Driver Location
Will this even work with
push notifications?
UBER
Realtime Technology
What do we need?
Connection
Topic
Subscription to Topics
Publish
• A pipe between the client and the server
• Identification of available data
• Client informs the server what it is interested in
• Deliver relevant data to the client in realtime
What do we need?
Frontend
Server
Connection
Subscriber
What do we need?
Frontend
Server
Pub/Sub
Server
Connection
Subscriber
What do we need?
Frontend
Server
Pub/Sub
Server
Connection
SubscriberSubscription
What do we need?
Frontend
Server
Pub/Sub
Server
Server rack
Connection
SubscriberSubscription
What do we need?
Frontend
Server
Pub/Sub
Server
Server rack
Connection
Subscriber
Subscription
What do we need?
Frontend
Server
Pub/Sub
Server
Connection
Subscriber
SubscriptionPublish
What do we need?
Frontend
Server
Pub/Sub
Server
Connection
Subscriber
SubscriptionPublish
4 Key Building Blocks
Connection
A persistent pipe
between the client
and the backend
Subscriber
Manage and store
client information
Subscription
Allow clients to
subscribe to topics.
Manage & store
subscriptions
Publish
Publish events on
topics. Deliver
events to
subscribed clients.
Connection
Frontend
Server
Play Java
Frontend
EVENTSOURCE INTERFACE
HTTP Long Poll with Server Sent Events
GET /connect HTTP/1.1
Accept: text/event-stream
EVENTSOURCE INTERFACE
HTTP Long Poll with Server Sent Events
HTTP/1.1 200 OK
- RESPONSE HEADERS -
Content-Type: text/event-stream
EVENTSOURCE INTERFACE
HTTP Long Poll with Server Sent Events
HTTP/1.1 200 OK
- RESPONSE HEADERS -
Content-Type: text/event-stream
- RESPONSE BODY -
data: {“typingIndicator” object}
EVENTSOURCE INTERFACE
HTTP Long Poll with Server Sent Events
HTTP/1.1 200 OK
- RESPONSE HEADERS -
Content-Type: text/event-stream
- RESPONSE BODY -
data: {“typingIndicator” object}
..
data: {“message” object}
EVENTSOURCE INTERFACE
HTTP Long Poll with Server Sent Events
HTTP/1.1 200 OK
- RESPONSE HEADERS -
Content-Type: text/event-stream
- RESPONSE BODY -
data: {“typingIndicator” object}
..
data: {“message” object}
..
data: {“location” object}
WEB
EventSource Client Libraries
var evtSource =
new EventSource("https://www.linkedin.com/realtime/connect");
evtSource.onmessage = function(e) {
var typingIndicator = JSON.parse(e.data);
}
IE SUPPORT
EventSource Client Libraries
https://github.com/remy/polyfills/blob/master/EventSource.js
ANDROID & IOS SUPPORT
EventSource Client Libraries
Android: https://github.com/tylerjroach/eventsource-android
Swift: https://github.com/inaka/EventSource
Obj-C: https://github.com/neilco/EventSource
PLAY & AKKA
Server: Accepting a EventSource connection
// Client A connects to the server and is assigned connectionIdA
public Result listen() {
}
PLAY & AKKA
Server: Accepting a EventSource connection
// Client A connects to the server and is assigned connectionIdA
public Result listen() {
return ok(EventSource.whenConnected(eventSource -> {
String connectionId = UUID.randomUUID().toString();
}));
}
PLAY & AKKA
Server: Accepting a EventSource connection
// Client A connects to the server and is assigned connectionIdA
public Result listen() {
return ok(EventSource.whenConnected(eventSource -> {
String connectionId = UUID.randomUUID().toString();
// construct an Akka Actor with the new EventSource
connection identified by a random connection identifier
Akka.system().actorOf(
ClientConnectionActor.props(connectionId, eventSource),
connectionId);
}));
}
Wait, what about Websockets?
WebSockets
• Much better to establish an EventSource
connection first.
• Upgrade to WebSockets when possible.
• Frameworks like socket.io can be used.
• Generally not a good idea to rely on
WebSockets as the first and only
connection mechanism.
• Proxies/Firewalls/Antivirus systems can
block it.
• Not available as an upgrade over HTTP/2.
Vanilla EventSource vs Socket.io
• Server to client push only
• Works over plain HTTP
• Built-in support in most client, server
frameworks
• Clean, Fast & Easy for most use cases
Vanilla EventSource
• Bi-directional communication
• Long Polling + WebSockets
• Built-in delivery acks
• Special socket.io libraries for most
client/server frameworks
• Advanced use cases
Socket.io
4 Key Building Blocks
Connection
A persistent pipe
between the client
and the backend
Subscriber
Manage and store
client information
Subscription
Allow clients to
subscribe to topics.
Manage & store
subscriptions
Publish
Publish events on
topics. Deliver
events to
subscribed clients.
4 Key Building Blocks
Connection
A persistent pipe
between the client
and the backend
Subscriber
Manage and store
client information
Subscription
Allow clients to
subscribe to topics.
Manage & store
subscriptions
Publish
Publish events on
topics. Deliver
events to
subscribed clients.
Subscriber
Frontend
Server
Connection Id
Frontend Server
Address
B
Subscriber
Frontend
Server
Pub/Sub
Server
Connection Id
Frontend Server
Address
B
Subscriber
Frontend
Server
Pub/Sub
Server
Connection Id
Frontend Server
Address
Play Java
Frontend
Java
Backend
Distributed
K/V store
B
4 Key Building Blocks
Connection
A persistent pipe
between the client
and the backend
Subscriber
Manage and store
client information
Subscription
Allow clients to
subscribe to topics.
Manage & store
subscriptions
Publish
Publish events on
topics. Deliver
events to
subscribed clients.
4 Key Building Blocks
Connection
A persistent pipe
between the client
and the backend
Subscriber
Manage and store
client information
Subscription
Allow clients to
subscribe to topics.
Manage & store
subscriptions
Publish
Publish events on
topics. Deliver
events to
subscribed clients.
Subscription
Server rack
User B
Typing Indicators
User B
Topic
Connection Id
B
Subscription
Frontend
Server
Pub/Sub
Server
Server rack
Connection Id
Frontend Server
Address
Connection IdTopic
B
Subscription
Frontend
Server
Pub/Sub
Server
Server rack
Connection Id
Frontend Server
Address
Topic Connection Id
B
Subscription
Frontend
Server
Pub/Sub
Server
Server rack
Connection Id
Frontend Server
Address
Topic Connection Id
Distributed
K/V store
B
4 Key Building Blocks
Connection
A persistent pipe
between the client
and the backend
Subscriber
Manage and store
client information
Subscription
Allow clients to
subscribe to topics.
Manage & store
subscriptions
Publish
Publish events on
topics. Deliver
events to
subscribed clients.
4 Key Building Blocks
Connection
A persistent pipe
between the client
and the backend
Subscriber
Manage and store
client information
Subscription
Allow clients to
subscribe to topics.
Manage & store
subscriptions
Publish
Publish events on
topics. Deliver
events to
subscribed clients.
Publish
Frontend
Server
Pub/Sub
Server
Connection Id
Frontend Server
Address
Topic Connection Id
Frontend
Server
B
A
C
Messaging Backend (Publisher)
Publish
Frontend
Server
Pub/Sub
Server
Connection Id
Frontend Server
Address
Topic Connection Id
Typing Indicators
User B
Topic
Frontend
Server
C
B
A
Publish
Frontend
Server
Pub/Sub
Server
Connection Id
Frontend Server
Address
Topic Connection Id
Topic
A
B
Frontend
Server
C
Publish
Frontend
Server
Pub/Sub
Server
Connection Id
Frontend Server
Address
Topic Connection Id
Topic
A
B
Frontend
Server
C
Publish
Frontend
Server
Pub/Sub
Server
Connection Id
Frontend Server
Address
Topic Connection Id
Topic
A
B
Frontend
Server
C
Publish
Frontend
Server
Pub/Sub
Server
Frontend Server
Address
Topic Connection Id
Topic
Connection Id
A
B
Frontend
Server
C
Publish
Frontend
Server
Pub/Sub
Server
Connection Id
Frontend Server
Address
Topic Connection Id
Topic
Connection Id
A
B
Frontend
Server
C
Publish
Frontend
Server
Pub/Sub
Server
Connection Id
Frontend Server
Address
Topic Connection Id
Connection Id
A
B
Frontend
Server
C
Topic
Publish
Frontend
Server
Pub/Sub
Server
Connection Id
Frontend Server
Address
Topic Connection Id
A
B
Frontend
Server
C
PLAY & AKKA
Server: Publishing on EventSource
eventSource.send(<typing indicator object>);
EVENTSOURCE INTERFACE FOR USER B
Publish
HTTP/1.1 200 OK
- RESPONSE HEADERS -
Content-Type: text/event-stream
- RESPONSE BODY -
data: {“User A is typing…” object}
4 Key Building Blocks
Connection
A persistent pipe
between the client
and the backend
Subscriber
Manage and store
client information
Subscription
Allow clients to
subscribe to topics.
Manage & store
subscriptions
Publish
Publish events on
topics. Deliver
events to
subscribed clients.
Alternative Pub/Sub Mechanism
Frontend
Server
Pub/Sub
Server
Connection
Subscriber
SubscriptionPublish
Pub/Sub with ActiveMQ
Frontend
Server
Connection
Publish
Pub/Sub with RabbitMQ
Frontend
Server
Connection
Publish
Pub/Sub with Redis
Frontend
Server
Connection
Publish
Performance & Scale
How many persistent connections can a single
machine hold?
Frontend
Server
> 100,000
We can hold a million connections with just 10
machines
LINKEDIN ENGINEERING BLOG
tinyurl.com/
linkedinscaling
Akhilesh Gupta & Cliff Snyder
>100K
LinkedIn Realtime Performance
Persistent Connections/machine
>100K
E2E Publish Latency
75ms
E2E Publish Latency
Frontend
Server
Pub/Sub
Server
t1
E2E Publish Latency
Frontend
Server
Pub/Sub
Server
t1
t2
t2-t1 = 75ms p90
LinkedIn Realtime Performance
Persistent Connections/machine
>100K
E2E Publish Latency
75ms
Why does this system scale?
Stateless, Horizontally Scalable System
Frontend
Server
Pub/Sub
Server
Frontend
Server
Frontend
Server
Frontend
Server
Pub/Sub
Server
Pub/Sub
Server
Pub/Sub
Server
Subscriber
Subscription
Distributed K/V Storage System
Key takeaways
R E A LT I M E C O N T E N T D E L I V E R Y
Enable dynamic instant experiences on your apps
S E M I R E A LT I M E T E C H N O L O G Y
Polling & Push notifications are good for 

simple use cases
Frontend
t0 t1 t2 t3
f
4 B U I L D I N G B L O C K S O F A R E A LT I M E P L A T F O R M
Connection, Subscriber, Subscription, Publish
C O N N E C T I O N
Eventsource/SSE great for most use cases
E V E N T S O U R C E / S S E
Built-in support in most server frameworks
Readily available client libraries
P U B L I S H / S U B S C R I B E R E A LT I M E P L A T F O R M
Can be built on any server/storage technology
Stateless, Horizontally scalable
>100K
Active Status
Online/Offline indicators
LINKEDIN REALTIME TECHNOLOGY
P U B L I S H / S U B S C R I B E R E A LT I M E P L A T F O R M
You can do it for your app!
R E A LT I M E E N G I N E E R , L I N K E D I N
@agupta03
t i n y . c c / m o b i l e e r a - p p t

More Related Content

PPTX
Best Practices You Must Apply to Secure Your APIs - Scott Morrison, SVP & Dis...
PDF
Building the Eventbrite API Ecosystem
PDF
BFF Pattern in Action: SoundCloud’s Microservices
PPTX
apidays LIVE India - REST the Events - REST APIs for Event-Driven Architectur...
PPTX
Mobile APIs: Optimizing APIs for Many Devices
PDF
apidays LIVE Helsinki & North - Serverless Bots in a Blink by Rachel White, D...
PPTX
History and Future of the Netflix API - Mashery Evolution of Distribution
PPTX
API Services: Harness the Power of Enterprise Infrastructure
Best Practices You Must Apply to Secure Your APIs - Scott Morrison, SVP & Dis...
Building the Eventbrite API Ecosystem
BFF Pattern in Action: SoundCloud’s Microservices
apidays LIVE India - REST the Events - REST APIs for Event-Driven Architectur...
Mobile APIs: Optimizing APIs for Many Devices
apidays LIVE Helsinki & North - Serverless Bots in a Blink by Rachel White, D...
History and Future of the Netflix API - Mashery Evolution of Distribution
API Services: Harness the Power of Enterprise Infrastructure

What's hot (19)

PDF
Consumer-centric API Design
PPTX
Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episod...
PDF
2015-11-cloudsoft-basho-brooklyn-riak
PPTX
Netflix API
PPTX
Redesigning the Netflix API - OSCON
PDF
SendGridDelivered_API_Workshop
PPTX
Supermondays twilio
PPTX
#ATAGTR2019 Presentation "Performance testing of Chatbot" By Sarah Lovely and...
PDF
Cloud Native Java with Spring Cloud Services
PPTX
Beyond Bearer: Token Binding as the Foundation for a More Secure Web
PPT
API 101 - Understanding APIs.
PDF
Leveraging the Security of AWS's Own APIs for Your App - AWS Serverless Web Day
PPTX
Practical API Security - PyCon 2018
PPTX
Maintaining the Front Door to Netflix
PDF
The liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
PPTX
API Strategy Evolution at Netflix
PDF
OWASP API Security Top 10 - Austin DevSecOps Days
PPTX
Mobile APIs in Practice
PDF
Hello SMS!
Consumer-centric API Design
Essential API Facade Patterns: Synchronous to Asynchronous Conversion (Episod...
2015-11-cloudsoft-basho-brooklyn-riak
Netflix API
Redesigning the Netflix API - OSCON
SendGridDelivered_API_Workshop
Supermondays twilio
#ATAGTR2019 Presentation "Performance testing of Chatbot" By Sarah Lovely and...
Cloud Native Java with Spring Cloud Services
Beyond Bearer: Token Binding as the Foundation for a More Secure Web
API 101 - Understanding APIs.
Leveraging the Security of AWS's Own APIs for Your App - AWS Serverless Web Day
Practical API Security - PyCon 2018
Maintaining the Front Door to Netflix
The liferay case: lessons learned evolving from RPC to Hypermedia REST APIs
API Strategy Evolution at Netflix
OWASP API Security Top 10 - Austin DevSecOps Days
Mobile APIs in Practice
Hello SMS!
Ad

Similar to Realtime Content Delivery: Powering dynamic instant experiences (20)

PDF
Scaling Push Messaging for Millions of Devices @Netflix
PDF
From Data Push to WebSockets
PDF
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
PDF
Real time web apps
PDF
From Push Technology to Real-Time Messaging and WebSockets
PPT
Camelone-2012 HTML5 WebSocket ActiveMQ/Camel
ZIP
ProcessOne Push Platform: XMPP-based Push Solutions
ZIP
ProcessOne Push Platform: XMPP-based Push Solutions
PDF
QCon London 2020: Streaming a million likes/second Real-time interactions on...
PPTX
Don't call us - we'll push - cross tier push architecture (JavaOne 2011)
PDF
Damien Tanner, Pusher
PDF
Adding Realtime to your Projects
PDF
Real-Time Web Apps in 2015 & Beyond
PDF
Server-Sent Events in Action
PPTX
Global Data Stream Network for Internet of Things
PDF
Information sharing pipeline
PPTX
Best practices of building data streaming API
PPTX
Don't call us - we'll push - on cross tier push architecture (NLJUG JFall 201...
PDF
Backend & Frontend architecture scalability & websockets
PPTX
Scaling Push Messaging for Millions of Netflix Devices
Scaling Push Messaging for Millions of Devices @Netflix
From Data Push to WebSockets
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Real time web apps
From Push Technology to Real-Time Messaging and WebSockets
Camelone-2012 HTML5 WebSocket ActiveMQ/Camel
ProcessOne Push Platform: XMPP-based Push Solutions
ProcessOne Push Platform: XMPP-based Push Solutions
QCon London 2020: Streaming a million likes/second Real-time interactions on...
Don't call us - we'll push - cross tier push architecture (JavaOne 2011)
Damien Tanner, Pusher
Adding Realtime to your Projects
Real-Time Web Apps in 2015 & Beyond
Server-Sent Events in Action
Global Data Stream Network for Internet of Things
Information sharing pipeline
Best practices of building data streaming API
Don't call us - we'll push - on cross tier push architecture (NLJUG JFall 201...
Backend & Frontend architecture scalability & websockets
Scaling Push Messaging for Millions of Netflix Devices
Ad

Recently uploaded (20)

PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Encapsulation theory and applications.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Spectroscopy.pptx food analysis technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Review of recent advances in non-invasive hemoglobin estimation
Encapsulation theory and applications.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Understanding_Digital_Forensics_Presentation.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
The AUB Centre for AI in Media Proposal.docx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Programs and apps: productivity, graphics, security and other tools
Mobile App Security Testing_ A Comprehensive Guide.pdf
cuic standard and advanced reporting.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Machine learning based COVID-19 study performance prediction
Spectroscopy.pptx food analysis technology
Encapsulation_ Review paper, used for researhc scholars
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx

Realtime Content Delivery: Powering dynamic instant experiences