SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Scaling Server-Sent Events (AKA Long Polling)
Stephen Ludin
Chief Architect, Akamai Technologies
What We Saw

09:51:23.051736 IP client.62471 >server.80: Flags [S], seq 233319732, win 65535
09:51:23.056777 IP server.80 >client.62471: Flags [S.], seq 227753171, ack 233319733, win 5792
09:51:23.056906 IP client.62471 >server.80: Flags [.], ack 1, win 32976
09:51:23.057034 IP client.62471 >server.80: Flags [P.], seq 1:156, ack 1, win 32976
09:51:23.061841 IP server.80 > client.62471: Flags [.], ack 156, win 215


And it just sat there…




Velocity 2011                            Powering a Better Internet                         ©2011 Akamai
Polling
                                                                  How much longer now?
 How much longer now?
                            How much longer now?
       How much longer now?                     How much longer now?

                                      How much longer now?                  How much longer now?
How much longer now?


     How much longer now?                                                    How much longer now?

                                         How much longer now?
 How much longer now?                                                         How much longer now?

                                                                   How much longer now?
                  How much longer now?

                                Dad, when are the fireworks starting?

  Velocity 2011                             Powering a Better Internet                        ©2011 Akamai
Long Polling




Velocity 2011   Powering a Better Internet   ©2011 Akamai
Long Polling – What is it?

A method for emulating „server push‟ and providing real time notifications
• Browser uses XMLHttpRequest to connect to origin and waits
• When there is data to send, the origin responds


Variants and frameworks:
• Long Polling
• Server-Sent Events
• HTTP Streaming
• Bayeux
• BOSH
• Comet


Velocity 2011                      Powering a Better Internet        ©2011 Akamai
Usage is growing




Velocity 2011      Powering a Better Internet   ©2011 Akamai
What‟s Changing




Velocity 2011     Powering a Better Internet   ©2011 Akamai
Requests For Help




Velocity 2011       Powering a Better Internet   ©2011 Akamai
The Challenges of Long-Polling for the Origin

Trading off high request rate (polling) for massive concurrent connections

Scaling at the Origin
• Not everyone has event-driven Web servers (Jetty, lighttpd, nginx)
• Still a lot of older architectures out there

What is really desired is a “Server Push” model

But despite all that, we still like long-polling
• Provides a “Real Time Web” without polling
• Makes modern HTTP applications possible


So: Is there a way to offload the connection load and provide server push?

Velocity 2011                           Powering a Better Internet           ©2011 Akamai
In Short…

Everyone wants to use long polling, but scaling is a challenge.

Addressing this scale problem will result in better origin performance.




Velocity 2011                  Powering a Better Internet             ©2011 Akamai
“Normal” HTTP Request Flow with a CDN




Velocity 2011           Powering a Better Internet   ©2011 Akamai
Long Poll HTTP Request Flow with a CDN




Velocity 2011            Powering a Better Internet   ©2011 Akamai
How can a CDN help?

Offload Via Edge Caching or Computing?

Acceleration?

Application of business logic?

Security / Web Application Firewall?




Velocity 2011                    Powering a Better Internet   ©2011 Akamai
Two Key Concepts

Half-Sync / Half-Async
• “Decouples synchronous I/O from asynchronous I/O in a system to simplify concurrent
programming effort” 1

Publish / Subscribe (Pub/Sub)
• The generic model behind most events




1 Douglas C. Schmidt and Charles D. Cranor, 1996, “Half-Sync/Half-Async: An Architectural Pattern for Efficient
  and Well-Structured Concurrent I/O”



Velocity 2011                                        Powering a Better Internet                                   ©2011 Akamai
Requesting an Event (Subscribe)

                                                       “User A wants Event 1”




                 T




                                                             User    Event        Token
                                                             A       1            T1
                                                             B       2            T2
                                                             C       1            T3

Velocity 2011             Powering a Better Internet                            ©2011 Akamai
Delivering the Event (Publish)

                “I‟ve Got Mail!”
                                                                    Event 2 Fired for User B!




                                                                              T


                                                                T

                                                                     User    Event     Token
                                                                     A       1         T1
                                                                     C
                                                                     B       1
                                                                             2         T3
                                                                                       T2
                                                                     C       1         T3

Velocity 2011                      Powering a Better Internet                        ©2011 Akamai
Half Sync / Half-Async Benefits

Provides the ability to scale

Enables “true” Server Push

Retains “real time” notification

Makes load balancing at the origin easier

Makes infrastructure management at the origin easier


Velocity 2011                      Powering a Better Internet   ©2011 Akamai
The Implementation

Token Construction
• Information needed to get back to the edge machine (IP)
• Customer specific code
• User information
• Subscription (Event) information
• Expiration




Velocity 2011                       Powering a Better Internet   ©2011 Akamai
The Implementation

On the Client:
• Use HTML 5 Server-Sent Events
• Use old fashioned long-polling
• Essentially, do what you do today




Velocity 2011                         Powering a Better Internet   ©2011 Akamai
The Implementation

On the Edge:
• Configure the surrogate to react appropriately




Velocity 2011                        Powering a Better Internet   ©2011 Akamai
The Implementation

For example, on Akamai:
<match:uri.component value=“subscribe-event”>
<variable:extract from=“post” key=“id” name=“EVENT”/>
<variable:extract from=“cookie” key=“user” name=“USER”/>
<edgeservices:event.handle-subscription>
<token>
<key>ywewu238347i3u</key>
<nonce-source>PORT</nonce-source>
</token>
<user>$(USER)</user>
<event-id>$(EVENT)</event-id>
</edgeservices:event.handle-subscription>
</match:uri.component>




Velocity 2011                Powering a Better Internet    ©2011 Akamai
The Implementation

And go Forward with:
POST /subscribe-event HTTP/1.1
Host: mail.foo.com
X-Event-Id: 2
X-Event-User: B
X-Event-Token: of2948f394fornvo334o343o4oejo23jf2
X-Event-Signature: f1d2d2f924e986ac86fdf7b36c94bcdf32beec15
...




Velocity 2011                Powering a Better Internet       ©2011 Akamai
The Implementation

On The Origin - Subscription
• Receive the subscription request
• Respond with a “202” (eg.) in the positive


On The Origin – Event Firing
• When event fires, send the event data
   • Sign token
   • Application specific, recommend SSE
• Fire and forget, persist, or stream




Velocity 2011                         Powering a Better Internet   ©2011 Akamai
The Implementation

POST /deliver-event HTTP/1.1
Host: event.foo.com
X-Event-Id: 2
X-Event-User: B
X-Event-Token: of2948f394fornvo334o343o4oejo23jf2
X-Event-Signature: e242ed3bffccdf271b7fbaf34ed72d089537b42f
Content-Length: 16

You’ve Got Mail!




Velocity 2011                Powering a Better Internet       ©2011 Akamai
Subscription Types

One Shot Event
• Force client reconnect (re-subscribe)




Velocity 2011                        Powering a Better Internet   ©2011 Akamai
Subscription Types (cont)

Repeatable Event
• Origin → CDN: Multiple Requests
• CDN → Client: HTTP Streaming




Velocity 2011                       Powering a Better Internet   ©2011 Akamai
Subscription Types (cont)

HTTP Streaming
• Similar to Multiple Events
• Potential for multiplexing




Velocity 2011                  Powering a Better Internet   ©2011 Akamai
Security

Risk: Bogus Event Injection

SSL on all sides will help
• Origin to CDN MUST be authenticated


The token MUST be secure
• Necessitates a shared secret or more expensive asymmetrical operations
• Replay protection




Velocity 2011                      Powering a Better Internet              ©2011 Akamai
Some Error Cases

Origin Rejects the subscription request
• An error is returned to the edge machine
• Edge machine delivers the error


Tokens are found to be invalid by some party
• Be paranoid
• Drop connections and force resubscription




Velocity 2011                        Powering a Better Internet   ©2011 Akamai
Error Cases (cont)

Client drops and reconnects
• If detected by edge machine, unsubscribe event can be fired
• Origin should detect multiple subscriptions and resolve
• Optional: If client also has a token it can be used to reconnect to the original edge
machine via redirect or tunneling


Edge machine „disappears‟
• Devolves (hopefully) to a client drop and reconnect




Velocity 2011                         Powering a Better Internet                      ©2011 Akamai
Error Cases (cont)

Annoying routers dropping quiet connections
• Heartbeat events can help (Wait! Isn‟t that polling?)
• Fortunately a well understood problem




Velocity 2011                         Powering a Better Internet   ©2011 Akamai
Mobile – Connectionless Push Friendly




Velocity 2011             Powering a Better Internet   ©2011 Akamai
What about WebSockets?

Not a good candidate (today)
• Bi-directional
• Opaque
Standard Acceleration techniques are ideal
Anticipating „standards‟ in the future




Velocity 2011                  Powering a Better Internet   ©2011 Akamai
Use Cases

E-Mail
• Millions of users want to know when they get new mail. Now.




Velocity 2011                       Powering a Better Internet   ©2011 Akamai
Use Cases

Social Networking
• What friends are online? What are they doing? I want to chat with them!




Velocity 2011                       Powering a Better Internet              ©2011 Akamai
Use Cases

Stock Quotes
• BSC: 78.34

• BSC: 75.56

• BSC: 38.12

• BSC: 3.12

• BSC: Delisted




Velocity 2011     Powering a Better Internet   ©2011 Akamai
Use Cases

Cloud Printing
• Printer manufacturer sells 100 million Internet-enabled printers and wants to enable
  cloud printing in a scalable and efficient manner.




Velocity 2011                        Powering a Better Internet                    ©2011 Akamai
Summary

Server-Sent Events is a great thing
• Introduces connection scaling problems
• Formalizes long-polling methodologies
• Useful whenever a user is expected to wait a „long time‟ for a reply

CDNs can help with the scaling problem
• Half-Sync / Half-Async
• Security Features
• Business Logic
• Acceleration

CDNs can provide a “server push” paradigm to the origin


Velocity 2011                         Powering a Better Internet         ©2011 Akamai
Questions




Velocity 2011   Powering a Better Internet   ©2011 Akamai

Weitere ähnliche Inhalte

Was ist angesagt?

Microservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring CloudMicroservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring CloudEberhard Wolff
 
Service-mesh options with Linkerd, Consul, Istio and AWS AppMesh
Service-mesh options with Linkerd, Consul, Istio and AWS AppMeshService-mesh options with Linkerd, Consul, Istio and AWS AppMesh
Service-mesh options with Linkerd, Consul, Istio and AWS AppMeshChristian Posta
 
CI/CD Tools Universe: The Ultimate List
CI/CD Tools Universe: The Ultimate ListCI/CD Tools Universe: The Ultimate List
CI/CD Tools Universe: The Ultimate ListPlutora
 
Cloud Native Bern 05.2023 — Zero Trust Visibility
Cloud Native Bern 05.2023 — Zero Trust VisibilityCloud Native Bern 05.2023 — Zero Trust Visibility
Cloud Native Bern 05.2023 — Zero Trust VisibilityRaphaël PINSON
 
Introducing KRaft: Kafka Without Zookeeper With Colin McCabe | Current 2022
Introducing KRaft: Kafka Without Zookeeper With Colin McCabe | Current 2022Introducing KRaft: Kafka Without Zookeeper With Colin McCabe | Current 2022
Introducing KRaft: Kafka Without Zookeeper With Colin McCabe | Current 2022HostedbyConfluent
 
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API ManagerWSO2
 
[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링
[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링
[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링OpenStack Korea Community
 
Introduction to Kafka connect
Introduction to Kafka connectIntroduction to Kafka connect
Introduction to Kafka connectKnoldus Inc.
 
Kafka for Real-Time Replication between Edge and Hybrid Cloud
Kafka for Real-Time Replication between Edge and Hybrid CloudKafka for Real-Time Replication between Edge and Hybrid Cloud
Kafka for Real-Time Replication between Edge and Hybrid CloudKai Wähner
 
Virtualizing the Network to enable a Software Defined Infrastructure (SDI)
Virtualizing the Network to enable a Software Defined Infrastructure (SDI)Virtualizing the Network to enable a Software Defined Infrastructure (SDI)
Virtualizing the Network to enable a Software Defined Infrastructure (SDI)Odinot Stanislas
 
Observability - Stockholm Splunk UG Jan 19 2023.pptx
Observability - Stockholm Splunk UG Jan 19 2023.pptxObservability - Stockholm Splunk UG Jan 19 2023.pptx
Observability - Stockholm Splunk UG Jan 19 2023.pptxMagnus Johansson
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetesRishabh Indoria
 
stupid-simple-kubernetes-final.pdf
stupid-simple-kubernetes-final.pdfstupid-simple-kubernetes-final.pdf
stupid-simple-kubernetes-final.pdfDaniloQueirozMota
 
Re:invent 2016 Container Scheduling, Execution and AWS Integration
Re:invent 2016 Container Scheduling, Execution and AWS IntegrationRe:invent 2016 Container Scheduling, Execution and AWS Integration
Re:invent 2016 Container Scheduling, Execution and AWS Integrationaspyker
 
API Management within a Microservice Architecture
API Management within a Microservice ArchitectureAPI Management within a Microservice Architecture
API Management within a Microservice ArchitectureWSO2
 
eBay Architecture
eBay Architecture eBay Architecture
eBay Architecture Tony Ng
 
GitOps 101 Presentation.pdf
GitOps 101 Presentation.pdfGitOps 101 Presentation.pdf
GitOps 101 Presentation.pdfssuser31375f
 
Building a WiFi Hotspot with NodeJS: Cisco Meraki - ExCap API
Building a WiFi Hotspot with NodeJS: Cisco Meraki - ExCap APIBuilding a WiFi Hotspot with NodeJS: Cisco Meraki - ExCap API
Building a WiFi Hotspot with NodeJS: Cisco Meraki - ExCap APICisco DevNet
 

Was ist angesagt? (20)

Microservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring CloudMicroservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring Cloud
 
Service-mesh options with Linkerd, Consul, Istio and AWS AppMesh
Service-mesh options with Linkerd, Consul, Istio and AWS AppMeshService-mesh options with Linkerd, Consul, Istio and AWS AppMesh
Service-mesh options with Linkerd, Consul, Istio and AWS AppMesh
 
CI/CD Tools Universe: The Ultimate List
CI/CD Tools Universe: The Ultimate ListCI/CD Tools Universe: The Ultimate List
CI/CD Tools Universe: The Ultimate List
 
Cloud Native Bern 05.2023 — Zero Trust Visibility
Cloud Native Bern 05.2023 — Zero Trust VisibilityCloud Native Bern 05.2023 — Zero Trust Visibility
Cloud Native Bern 05.2023 — Zero Trust Visibility
 
Apache NiFi Crash Course Intro
Apache NiFi Crash Course IntroApache NiFi Crash Course Intro
Apache NiFi Crash Course Intro
 
Introducing KRaft: Kafka Without Zookeeper With Colin McCabe | Current 2022
Introducing KRaft: Kafka Without Zookeeper With Colin McCabe | Current 2022Introducing KRaft: Kafka Without Zookeeper With Colin McCabe | Current 2022
Introducing KRaft: Kafka Without Zookeeper With Colin McCabe | Current 2022
 
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
[WSO2 API Manager Community Call] Mastering JWTs with WSO2 API Manager
 
[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링
[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링
[OpenInfra Days Korea 2018] (Track 4) - Grafana를 이용한 OpenStack 클라우드 성능 모니터링
 
Introduction to Kafka connect
Introduction to Kafka connectIntroduction to Kafka connect
Introduction to Kafka connect
 
Service mesh
Service meshService mesh
Service mesh
 
Kafka for Real-Time Replication between Edge and Hybrid Cloud
Kafka for Real-Time Replication between Edge and Hybrid CloudKafka for Real-Time Replication between Edge and Hybrid Cloud
Kafka for Real-Time Replication between Edge and Hybrid Cloud
 
Virtualizing the Network to enable a Software Defined Infrastructure (SDI)
Virtualizing the Network to enable a Software Defined Infrastructure (SDI)Virtualizing the Network to enable a Software Defined Infrastructure (SDI)
Virtualizing the Network to enable a Software Defined Infrastructure (SDI)
 
Observability - Stockholm Splunk UG Jan 19 2023.pptx
Observability - Stockholm Splunk UG Jan 19 2023.pptxObservability - Stockholm Splunk UG Jan 19 2023.pptx
Observability - Stockholm Splunk UG Jan 19 2023.pptx
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
stupid-simple-kubernetes-final.pdf
stupid-simple-kubernetes-final.pdfstupid-simple-kubernetes-final.pdf
stupid-simple-kubernetes-final.pdf
 
Re:invent 2016 Container Scheduling, Execution and AWS Integration
Re:invent 2016 Container Scheduling, Execution and AWS IntegrationRe:invent 2016 Container Scheduling, Execution and AWS Integration
Re:invent 2016 Container Scheduling, Execution and AWS Integration
 
API Management within a Microservice Architecture
API Management within a Microservice ArchitectureAPI Management within a Microservice Architecture
API Management within a Microservice Architecture
 
eBay Architecture
eBay Architecture eBay Architecture
eBay Architecture
 
GitOps 101 Presentation.pdf
GitOps 101 Presentation.pdfGitOps 101 Presentation.pdf
GitOps 101 Presentation.pdf
 
Building a WiFi Hotspot with NodeJS: Cisco Meraki - ExCap API
Building a WiFi Hotspot with NodeJS: Cisco Meraki - ExCap APIBuilding a WiFi Hotspot with NodeJS: Cisco Meraki - ExCap API
Building a WiFi Hotspot with NodeJS: Cisco Meraki - ExCap API
 

Ähnlich wie Addressing the scalability challenge of server sent events presentation

SignalR for ASP.NET Developers
SignalR for ASP.NET DevelopersSignalR for ASP.NET Developers
SignalR for ASP.NET DevelopersShivanand Arur
 
Keystone - ApacheCon 2016
Keystone - ApacheCon 2016Keystone - ApacheCon 2016
Keystone - ApacheCon 2016Peter Bakas
 
OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...
OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...
OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...Masaaki Nakagawa
 
NTTs Journey with Openstack-final
NTTs Journey with Openstack-finalNTTs Journey with Openstack-final
NTTs Journey with Openstack-finalshintaro mizuno
 
Big datadc skyfall_preso_v2
Big datadc skyfall_preso_v2Big datadc skyfall_preso_v2
Big datadc skyfall_preso_v2abramsm
 
Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuli...
Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuli...Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuli...
Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuli...Codemotion
 
Stateful Stream Processing at In-Memory Speed
Stateful Stream Processing at In-Memory SpeedStateful Stream Processing at In-Memory Speed
Stateful Stream Processing at In-Memory SpeedJamie Grier
 
SignalR With ASP.Net part1
SignalR With ASP.Net part1SignalR With ASP.Net part1
SignalR With ASP.Net part1Esraa Ammar
 
Data Warehousing Infrastructure on Cloud
Data Warehousing Infrastructure on CloudData Warehousing Infrastructure on Cloud
Data Warehousing Infrastructure on Cloudtdwiindia
 
Understanding Akka WebSockets A Comprehensive Guide.pptx
Understanding Akka WebSockets A Comprehensive Guide.pptxUnderstanding Akka WebSockets A Comprehensive Guide.pptx
Understanding Akka WebSockets A Comprehensive Guide.pptxKnoldus Inc.
 
Understanding Akka WebSockets A Comprehensive Guide
Understanding Akka WebSockets A Comprehensive GuideUnderstanding Akka WebSockets A Comprehensive Guide
Understanding Akka WebSockets A Comprehensive GuideKnoldus Inc.
 
10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamai
10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamai10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamai
10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamaielenae00
 
10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamai
10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamai10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamai
10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamaielenae00
 
Actors or Not: Async Event Architectures
Actors or Not: Async Event ArchitecturesActors or Not: Async Event Architectures
Actors or Not: Async Event ArchitecturesYaroslav Tkachenko
 
Kranky Geek WebRTC 2015 - Optimizing the customer experience
Kranky Geek WebRTC 2015 - Optimizing the customer experienceKranky Geek WebRTC 2015 - Optimizing the customer experience
Kranky Geek WebRTC 2015 - Optimizing the customer experienceKranky Geek
 
(power point slides)
(power point slides)(power point slides)
(power point slides)webhostingguy
 
Advanced Stream Processing with Flink and Pulsar - Pulsar Summit NA 2021 Keynote
Advanced Stream Processing with Flink and Pulsar - Pulsar Summit NA 2021 KeynoteAdvanced Stream Processing with Flink and Pulsar - Pulsar Summit NA 2021 Keynote
Advanced Stream Processing with Flink and Pulsar - Pulsar Summit NA 2021 KeynoteStreamNative
 

Ähnlich wie Addressing the scalability challenge of server sent events presentation (20)

SignalR for ASP.NET Developers
SignalR for ASP.NET DevelopersSignalR for ASP.NET Developers
SignalR for ASP.NET Developers
 
Keystone - ApacheCon 2016
Keystone - ApacheCon 2016Keystone - ApacheCon 2016
Keystone - ApacheCon 2016
 
OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...
OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...
OpenStack Summit Tokyo - Know-how of Challlenging Deploy/Operation NTT DOCOMO...
 
NTTs Journey with Openstack-final
NTTs Journey with Openstack-finalNTTs Journey with Openstack-final
NTTs Journey with Openstack-final
 
Big datadc skyfall_preso_v2
Big datadc skyfall_preso_v2Big datadc skyfall_preso_v2
Big datadc skyfall_preso_v2
 
Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuli...
Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuli...Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuli...
Webhooks do's and dont's: what we learned after integrating +100 APIs - Giuli...
 
Stateful Stream Processing at In-Memory Speed
Stateful Stream Processing at In-Memory SpeedStateful Stream Processing at In-Memory Speed
Stateful Stream Processing at In-Memory Speed
 
Websocket
WebsocketWebsocket
Websocket
 
SignalR With ASP.Net part1
SignalR With ASP.Net part1SignalR With ASP.Net part1
SignalR With ASP.Net part1
 
Data Warehousing Infrastructure on Cloud
Data Warehousing Infrastructure on CloudData Warehousing Infrastructure on Cloud
Data Warehousing Infrastructure on Cloud
 
Understanding Akka WebSockets A Comprehensive Guide.pptx
Understanding Akka WebSockets A Comprehensive Guide.pptxUnderstanding Akka WebSockets A Comprehensive Guide.pptx
Understanding Akka WebSockets A Comprehensive Guide.pptx
 
Understanding Akka WebSockets A Comprehensive Guide
Understanding Akka WebSockets A Comprehensive GuideUnderstanding Akka WebSockets A Comprehensive Guide
Understanding Akka WebSockets A Comprehensive Guide
 
ServerSentEvents.pdf
ServerSentEvents.pdfServerSentEvents.pdf
ServerSentEvents.pdf
 
10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamai
10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamai10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamai
10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamai
 
10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamai
10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamai10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamai
10+апреля+лучшие+практики+и+инновации+вадим+береговский+akamai
 
Actors or Not: Async Event Architectures
Actors or Not: Async Event ArchitecturesActors or Not: Async Event Architectures
Actors or Not: Async Event Architectures
 
Kranky Geek WebRTC 2015 - Optimizing the customer experience
Kranky Geek WebRTC 2015 - Optimizing the customer experienceKranky Geek WebRTC 2015 - Optimizing the customer experience
Kranky Geek WebRTC 2015 - Optimizing the customer experience
 
(power point slides)
(power point slides)(power point slides)
(power point slides)
 
Scalenics overview
Scalenics overviewScalenics overview
Scalenics overview
 
Advanced Stream Processing with Flink and Pulsar - Pulsar Summit NA 2021 Keynote
Advanced Stream Processing with Flink and Pulsar - Pulsar Summit NA 2021 KeynoteAdvanced Stream Processing with Flink and Pulsar - Pulsar Summit NA 2021 Keynote
Advanced Stream Processing with Flink and Pulsar - Pulsar Summit NA 2021 Keynote
 

Kürzlich hochgeladen

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 

Kürzlich hochgeladen (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

Addressing the scalability challenge of server sent events presentation

  • 1. Scaling Server-Sent Events (AKA Long Polling) Stephen Ludin Chief Architect, Akamai Technologies
  • 2. What We Saw 09:51:23.051736 IP client.62471 >server.80: Flags [S], seq 233319732, win 65535 09:51:23.056777 IP server.80 >client.62471: Flags [S.], seq 227753171, ack 233319733, win 5792 09:51:23.056906 IP client.62471 >server.80: Flags [.], ack 1, win 32976 09:51:23.057034 IP client.62471 >server.80: Flags [P.], seq 1:156, ack 1, win 32976 09:51:23.061841 IP server.80 > client.62471: Flags [.], ack 156, win 215 And it just sat there… Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 3. Polling How much longer now? How much longer now? How much longer now? How much longer now? How much longer now? How much longer now? How much longer now? How much longer now? How much longer now? How much longer now? How much longer now? How much longer now? How much longer now? How much longer now? How much longer now? Dad, when are the fireworks starting? Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 4. Long Polling Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 5. Long Polling – What is it? A method for emulating „server push‟ and providing real time notifications • Browser uses XMLHttpRequest to connect to origin and waits • When there is data to send, the origin responds Variants and frameworks: • Long Polling • Server-Sent Events • HTTP Streaming • Bayeux • BOSH • Comet Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 6. Usage is growing Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 7. What‟s Changing Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 8. Requests For Help Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 9. The Challenges of Long-Polling for the Origin Trading off high request rate (polling) for massive concurrent connections Scaling at the Origin • Not everyone has event-driven Web servers (Jetty, lighttpd, nginx) • Still a lot of older architectures out there What is really desired is a “Server Push” model But despite all that, we still like long-polling • Provides a “Real Time Web” without polling • Makes modern HTTP applications possible So: Is there a way to offload the connection load and provide server push? Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 10. In Short… Everyone wants to use long polling, but scaling is a challenge. Addressing this scale problem will result in better origin performance. Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 11. “Normal” HTTP Request Flow with a CDN Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 12. Long Poll HTTP Request Flow with a CDN Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 13. How can a CDN help? Offload Via Edge Caching or Computing? Acceleration? Application of business logic? Security / Web Application Firewall? Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 14. Two Key Concepts Half-Sync / Half-Async • “Decouples synchronous I/O from asynchronous I/O in a system to simplify concurrent programming effort” 1 Publish / Subscribe (Pub/Sub) • The generic model behind most events 1 Douglas C. Schmidt and Charles D. Cranor, 1996, “Half-Sync/Half-Async: An Architectural Pattern for Efficient and Well-Structured Concurrent I/O” Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 15. Requesting an Event (Subscribe) “User A wants Event 1” T User Event Token A 1 T1 B 2 T2 C 1 T3 Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 16. Delivering the Event (Publish) “I‟ve Got Mail!” Event 2 Fired for User B! T T User Event Token A 1 T1 C B 1 2 T3 T2 C 1 T3 Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 17. Half Sync / Half-Async Benefits Provides the ability to scale Enables “true” Server Push Retains “real time” notification Makes load balancing at the origin easier Makes infrastructure management at the origin easier Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 18. The Implementation Token Construction • Information needed to get back to the edge machine (IP) • Customer specific code • User information • Subscription (Event) information • Expiration Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 19. The Implementation On the Client: • Use HTML 5 Server-Sent Events • Use old fashioned long-polling • Essentially, do what you do today Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 20. The Implementation On the Edge: • Configure the surrogate to react appropriately Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 21. The Implementation For example, on Akamai: <match:uri.component value=“subscribe-event”> <variable:extract from=“post” key=“id” name=“EVENT”/> <variable:extract from=“cookie” key=“user” name=“USER”/> <edgeservices:event.handle-subscription> <token> <key>ywewu238347i3u</key> <nonce-source>PORT</nonce-source> </token> <user>$(USER)</user> <event-id>$(EVENT)</event-id> </edgeservices:event.handle-subscription> </match:uri.component> Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 22. The Implementation And go Forward with: POST /subscribe-event HTTP/1.1 Host: mail.foo.com X-Event-Id: 2 X-Event-User: B X-Event-Token: of2948f394fornvo334o343o4oejo23jf2 X-Event-Signature: f1d2d2f924e986ac86fdf7b36c94bcdf32beec15 ... Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 23. The Implementation On The Origin - Subscription • Receive the subscription request • Respond with a “202” (eg.) in the positive On The Origin – Event Firing • When event fires, send the event data • Sign token • Application specific, recommend SSE • Fire and forget, persist, or stream Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 24. The Implementation POST /deliver-event HTTP/1.1 Host: event.foo.com X-Event-Id: 2 X-Event-User: B X-Event-Token: of2948f394fornvo334o343o4oejo23jf2 X-Event-Signature: e242ed3bffccdf271b7fbaf34ed72d089537b42f Content-Length: 16 You’ve Got Mail! Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 25. Subscription Types One Shot Event • Force client reconnect (re-subscribe) Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 26. Subscription Types (cont) Repeatable Event • Origin → CDN: Multiple Requests • CDN → Client: HTTP Streaming Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 27. Subscription Types (cont) HTTP Streaming • Similar to Multiple Events • Potential for multiplexing Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 28. Security Risk: Bogus Event Injection SSL on all sides will help • Origin to CDN MUST be authenticated The token MUST be secure • Necessitates a shared secret or more expensive asymmetrical operations • Replay protection Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 29. Some Error Cases Origin Rejects the subscription request • An error is returned to the edge machine • Edge machine delivers the error Tokens are found to be invalid by some party • Be paranoid • Drop connections and force resubscription Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 30. Error Cases (cont) Client drops and reconnects • If detected by edge machine, unsubscribe event can be fired • Origin should detect multiple subscriptions and resolve • Optional: If client also has a token it can be used to reconnect to the original edge machine via redirect or tunneling Edge machine „disappears‟ • Devolves (hopefully) to a client drop and reconnect Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 31. Error Cases (cont) Annoying routers dropping quiet connections • Heartbeat events can help (Wait! Isn‟t that polling?) • Fortunately a well understood problem Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 32. Mobile – Connectionless Push Friendly Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 33. What about WebSockets? Not a good candidate (today) • Bi-directional • Opaque Standard Acceleration techniques are ideal Anticipating „standards‟ in the future Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 34. Use Cases E-Mail • Millions of users want to know when they get new mail. Now. Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 35. Use Cases Social Networking • What friends are online? What are they doing? I want to chat with them! Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 36. Use Cases Stock Quotes • BSC: 78.34 • BSC: 75.56 • BSC: 38.12 • BSC: 3.12 • BSC: Delisted Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 37. Use Cases Cloud Printing • Printer manufacturer sells 100 million Internet-enabled printers and wants to enable cloud printing in a scalable and efficient manner. Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 38. Summary Server-Sent Events is a great thing • Introduces connection scaling problems • Formalizes long-polling methodologies • Useful whenever a user is expected to wait a „long time‟ for a reply CDNs can help with the scaling problem • Half-Sync / Half-Async • Security Features • Business Logic • Acceleration CDNs can provide a “server push” paradigm to the origin Velocity 2011 Powering a Better Internet ©2011 Akamai
  • 39. Questions Velocity 2011 Powering a Better Internet ©2011 Akamai

Hinweis der Redaktion

  1. Talk about the implications of SSEMention XSLTAjaxCometOrbitedReal Time WebXMPP over HTTP
  2. Holding connections open in memory or computationally expensive
  3. Talk about what is a CDN - Caching - Acceleration - Your new front door - Security
  4. Stuck in the mindset that we cannot offload this traffic. It is ‘no-store’
  5. Be clear about the token
  6. Preserve Battery life, etc.iMessenger