SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
“Because as rapid as the arrival of
     networked pull media was,
     the second act - networked push
     media - is coming even faster. ”
                           WIRED Magazine
                           March 1997




Thursday, March 11, 2010
Push
                                A 2010 case study with
                           the NGINX HTTP Push Module,
                               Ruby on Rails, and friends



                                    Luke Melia




Thursday, March 11, 2010
Who’s this guy?
                ★ VP, Engineering at weplay.com
                ★ Agilist
                ★ nyc.rb’er since ~2006
                ★ Ruby in Practice contributor
                ★ Interested in startup tech leadership
                ★ Beach volleyball player
                ★ Dad

Thursday, March 11, 2010
What’s this talk?
              ★ The goal and the problem
              ★ A quick survey of solutions
              ★ About the NGINX HTTP Push Module
              ★ How to use it with Ruby, by example
              ★ Gotchyas
              ★Q &A

Thursday, March 11, 2010
The Goal
    ★ Immediate encouragement
           of positive on-site actions
    ★ “Points!”


Thursday, March 11, 2010
+10


Thursday, March 11, 2010
Constraints
                 ★ Don’t want to figure out points earned
                           while processing the request (offload it to a
                           background work queue)
                 ★ Do want to inform about points earned
                           through another user’s actions
                 ★ Don’t want to wait for a second page load




Thursday, March 11, 2010
Pure push
               doesn’t exist
             on the open web

Thursday, March 11, 2010
XMPP                  WebSockets

                           Push-like
                           solutions
      Streaming                   Comet
Thursday, March 11, 2010
★       Don’t close the connection after
                  sending down the page
          ★       multipart/x-mixed-replace
          ★       Supported in non-Microsoft
                  browsers only


      Streaming
Thursday, March 11, 2010
XMPP
          ★       Designed for presence and messaging
          ★       Browsers don’t speak XMPP natively
          ★       BOSH
          ★       Hemlock: Flex + ejabberd, by NYC’s
                  Mint Digital

Thursday, March 11, 2010
★       Push data over a long held Ajax
                  request using browser-native
                  technologies
          ★       Bayeaux protocol
          ★       Long-polling Ajax


                                         Comet
Thursday, March 11, 2010
WebSockets
          ★       HTML 5
          ★       Full-duplex single socket connection
                  between browser and server
          ★       ex: ws://websockets.org:8787
          ★       very limited browser support today

Thursday, March 11, 2010
XMPP               WebSockets




      Streaming               Comet
Thursday, March 11, 2010
ejabberd                       Sunshowers


                                             Rainbows!
                             Servers              Cramp


     Juggernaut                    NGINX HTTP Push Module

                           Orbited
                             Tornado
                                Diesel          Faye

Thursday, March 11, 2010
NGINX HTTP Push Module

                    ★      Turns NGINX into a Comet server
                    ★      “A useful tool with a boring name.”
                    ★      By Leo P
                    ★      http://pushmodule.slact.net/
                    ★      Currently at 0.692β


Thursday, March 11, 2010
Basic HTTP Push
                                Relay Protocol
                           ★   Subscriber locations
                               ★   HTTP GET with channel ID
                           ★   Publisher locations
                               ★   HTTP POST with channel ID
                           ★   POSTed data is passed through,
                               becoming the response to the
                               subscriber’s GET

Thursday, March 11, 2010
Diagramming the simple case
                                                  BACK-END
                                                  PROCESS



                                 2. HTTP POST

                                                       Publisher endpoint


                                                                            3. POST BODY
                                                     NGINX
                                                                            IS ROUTED BY
                                                                             CHANNEL ID
                                         Subscriber endpoint



                                                               4. RESPONSE IS
                                1. HTTP GET                     DATA FROM
                                                                 POST BODY


                                                End User




Thursday, March 11, 2010
Channel
                           Concurrency Styles

                             ★ Broadcast

                             ★ Last-in, first-out

                             ★ First-in, last-out




Thursday, March 11, 2010
Subscriber config

             # public long‐polling endpoint
             location /rt/notifications {
               push_subscriber;
               set $push_channel_id $arg_id;
               push_subscriber_concurrency last;
             }

Thursday, March 11, 2010
Publisher config
       # internal publish endpoint
       # (keep it private / protected)
       location /rt/publish {
         push_publisher;
         set $push_channel_id $arg_id;
         push_store_messages on;
         push_message_timeout 5m;
         push_max_message_buffer_length 5;
         push_min_message_buffer_length 0;
         push_delete_oldest_received_message on;
       }
Thursday, March 11, 2010
Diagram with storage
                                                    BACK-END
                                                    PROCESS



                                   1. HTTP POST


                             4. MESSAGE                  Publisher endpoint

                                                                               2. POST BODY
                            IS RETRIEVED
                                                                                 IS QUEUED
                            FROM QUEUE                 NGINX
                                                                   Queue
                                                                              BY CHANNEL ID
                           BY CHANNEL ID
                                           Subscriber endpoint



                                                                 5. RESPONSE IS
                                 3. HTTP GET                      DATA FROM
                                                                     QUEUE


                                                  End User




Thursday, March 11, 2010
Code it up.




Thursday, March 11, 2010
Client-side Gotchas
                    ★      Javascript blocking
                           ★   Put it in an iframe
                    ★      Per domain connection limit
                           ★   use subdomain, with JSONP



Thursday, March 11, 2010
Server-side Gotchas
                ★          “Too many open connections”
                      ★    Reduce worker_connections to less
                           than ulimit -n
                      ★    Increase worker_processes to give
                           you enough total connection to
                           serve your users
                      ★    Ours: worker_processes 24
                                 worker_connections 960
Thursday, March 11, 2010
Testing


                    ★      Fake Publisher for in-memory
                           cucumber scenarios
                    ★      Run selenium scenarios through
                           NGINX to incorporate actual
                           push module behavior

Thursday, March 11, 2010
NGINX Configuration
                   Management

                           ★Template   it
                           ★Version
                                  it
                           ★Automate it


Thursday, March 11, 2010
The Future
                           ★   Multiplexing: subscribe
                               to more than one
                               channel
                           ★   Use Redis as a
                               message store
                           ★   Convention-based
                               approach for raising
                               javascript events


Thursday, March 11, 2010
Questions?




Thursday, March 11, 2010

Weitere ähnliche Inhalte

Ähnlich wie Http Push

BRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQLBRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQLAndreas Jung
 
Intro to WebSockets and Comet
Intro to WebSockets and CometIntro to WebSockets and Comet
Intro to WebSockets and Cometdylanks
 
HTTP2 in action - Piet Van Dongen - Codemotion Amsterdam 2017
HTTP2 in action - Piet Van Dongen - Codemotion Amsterdam 2017HTTP2 in action - Piet Van Dongen - Codemotion Amsterdam 2017
HTTP2 in action - Piet Van Dongen - Codemotion Amsterdam 2017Codemotion
 
A Network Architecture for the Web of Things
A Network Architecture for the Web of ThingsA Network Architecture for the Web of Things
A Network Architecture for the Web of Thingsbenaam
 
The Reluctant SysAdmin : 360|iDev Austin 2010
The Reluctant SysAdmin : 360|iDev Austin 2010The Reluctant SysAdmin : 360|iDev Austin 2010
The Reluctant SysAdmin : 360|iDev Austin 2010Voxilate
 
How To Build A Web Service
How To Build A Web ServiceHow To Build A Web Service
How To Build A Web ServiceMoses Ngone
 
Distributed Social Networking
Distributed Social NetworkingDistributed Social Networking
Distributed Social NetworkingBastian Hofmann
 
SeaBeyond 2011 ProcessOne - Eric Cestari: XMPP over WebSocket
SeaBeyond 2011 ProcessOne - Eric Cestari: XMPP over WebSocketSeaBeyond 2011 ProcessOne - Eric Cestari: XMPP over WebSocket
SeaBeyond 2011 ProcessOne - Eric Cestari: XMPP over WebSocketProcessOne
 
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands Bastian Hofmann
 
PHP in a Mobile Ecosystem (Zendcon 2010)
PHP in a Mobile Ecosystem (Zendcon 2010)PHP in a Mobile Ecosystem (Zendcon 2010)
PHP in a Mobile Ecosystem (Zendcon 2010)Ivo Jansch
 
Large Files without the Trials
Large Files without the TrialsLarge Files without the Trials
Large Files without the TrialsSally Kleinfeldt
 
Networks Have Layers - Understanding The OSI Model
Networks Have Layers - Understanding The OSI ModelNetworks Have Layers - Understanding The OSI Model
Networks Have Layers - Understanding The OSI ModelBrandon Checketts
 

Ähnlich wie Http Push (16)

BRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQLBRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQL
 
Intro to WebSockets and Comet
Intro to WebSockets and CometIntro to WebSockets and Comet
Intro to WebSockets and Comet
 
Node.js and Ruby
Node.js and RubyNode.js and Ruby
Node.js and Ruby
 
HTTP2 in action - Piet Van Dongen - Codemotion Amsterdam 2017
HTTP2 in action - Piet Van Dongen - Codemotion Amsterdam 2017HTTP2 in action - Piet Van Dongen - Codemotion Amsterdam 2017
HTTP2 in action - Piet Van Dongen - Codemotion Amsterdam 2017
 
A Network Architecture for the Web of Things
A Network Architecture for the Web of ThingsA Network Architecture for the Web of Things
A Network Architecture for the Web of Things
 
The Reluctant SysAdmin : 360|iDev Austin 2010
The Reluctant SysAdmin : 360|iDev Austin 2010The Reluctant SysAdmin : 360|iDev Austin 2010
The Reluctant SysAdmin : 360|iDev Austin 2010
 
Node.js - A Quick Tour II
Node.js - A Quick Tour IINode.js - A Quick Tour II
Node.js - A Quick Tour II
 
Intro To Git
Intro To GitIntro To Git
Intro To Git
 
How To Build A Web Service
How To Build A Web ServiceHow To Build A Web Service
How To Build A Web Service
 
Distributed Social Networking
Distributed Social NetworkingDistributed Social Networking
Distributed Social Networking
 
SeaBeyond 2011 ProcessOne - Eric Cestari: XMPP over WebSocket
SeaBeyond 2011 ProcessOne - Eric Cestari: XMPP over WebSocketSeaBeyond 2011 ProcessOne - Eric Cestari: XMPP over WebSocket
SeaBeyond 2011 ProcessOne - Eric Cestari: XMPP over WebSocket
 
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands
 
RunDeck
RunDeckRunDeck
RunDeck
 
PHP in a Mobile Ecosystem (Zendcon 2010)
PHP in a Mobile Ecosystem (Zendcon 2010)PHP in a Mobile Ecosystem (Zendcon 2010)
PHP in a Mobile Ecosystem (Zendcon 2010)
 
Large Files without the Trials
Large Files without the TrialsLarge Files without the Trials
Large Files without the Trials
 
Networks Have Layers - Understanding The OSI Model
Networks Have Layers - Understanding The OSI ModelNetworks Have Layers - Understanding The OSI Model
Networks Have Layers - Understanding The OSI Model
 

Kürzlich hochgeladen

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Kürzlich hochgeladen (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 

Http Push

  • 1. “Because as rapid as the arrival of networked pull media was, the second act - networked push media - is coming even faster. ” WIRED Magazine March 1997 Thursday, March 11, 2010
  • 2. Push A 2010 case study with the NGINX HTTP Push Module, Ruby on Rails, and friends Luke Melia Thursday, March 11, 2010
  • 3. Who’s this guy? ★ VP, Engineering at weplay.com ★ Agilist ★ nyc.rb’er since ~2006 ★ Ruby in Practice contributor ★ Interested in startup tech leadership ★ Beach volleyball player ★ Dad Thursday, March 11, 2010
  • 4. What’s this talk? ★ The goal and the problem ★ A quick survey of solutions ★ About the NGINX HTTP Push Module ★ How to use it with Ruby, by example ★ Gotchyas ★Q &A Thursday, March 11, 2010
  • 5. The Goal ★ Immediate encouragement of positive on-site actions ★ “Points!” Thursday, March 11, 2010
  • 7. Constraints ★ Don’t want to figure out points earned while processing the request (offload it to a background work queue) ★ Do want to inform about points earned through another user’s actions ★ Don’t want to wait for a second page load Thursday, March 11, 2010
  • 8. Pure push doesn’t exist on the open web Thursday, March 11, 2010
  • 9. XMPP WebSockets Push-like solutions Streaming Comet Thursday, March 11, 2010
  • 10. Don’t close the connection after sending down the page ★ multipart/x-mixed-replace ★ Supported in non-Microsoft browsers only Streaming Thursday, March 11, 2010
  • 11. XMPP ★ Designed for presence and messaging ★ Browsers don’t speak XMPP natively ★ BOSH ★ Hemlock: Flex + ejabberd, by NYC’s Mint Digital Thursday, March 11, 2010
  • 12. Push data over a long held Ajax request using browser-native technologies ★ Bayeaux protocol ★ Long-polling Ajax Comet Thursday, March 11, 2010
  • 13. WebSockets ★ HTML 5 ★ Full-duplex single socket connection between browser and server ★ ex: ws://websockets.org:8787 ★ very limited browser support today Thursday, March 11, 2010
  • 14. XMPP WebSockets Streaming Comet Thursday, March 11, 2010
  • 15. ejabberd Sunshowers Rainbows! Servers Cramp Juggernaut NGINX HTTP Push Module Orbited Tornado Diesel Faye Thursday, March 11, 2010
  • 16. NGINX HTTP Push Module ★ Turns NGINX into a Comet server ★ “A useful tool with a boring name.” ★ By Leo P ★ http://pushmodule.slact.net/ ★ Currently at 0.692β Thursday, March 11, 2010
  • 17. Basic HTTP Push Relay Protocol ★ Subscriber locations ★ HTTP GET with channel ID ★ Publisher locations ★ HTTP POST with channel ID ★ POSTed data is passed through, becoming the response to the subscriber’s GET Thursday, March 11, 2010
  • 18. Diagramming the simple case BACK-END PROCESS 2. HTTP POST Publisher endpoint 3. POST BODY NGINX IS ROUTED BY CHANNEL ID Subscriber endpoint 4. RESPONSE IS 1. HTTP GET DATA FROM POST BODY End User Thursday, March 11, 2010
  • 19. Channel Concurrency Styles ★ Broadcast ★ Last-in, first-out ★ First-in, last-out Thursday, March 11, 2010
  • 20. Subscriber config # public long‐polling endpoint location /rt/notifications {   push_subscriber;   set $push_channel_id $arg_id;   push_subscriber_concurrency last; } Thursday, March 11, 2010
  • 21. Publisher config # internal publish endpoint # (keep it private / protected) location /rt/publish {   push_publisher;   set $push_channel_id $arg_id;   push_store_messages on;   push_message_timeout 5m;   push_max_message_buffer_length 5;   push_min_message_buffer_length 0;   push_delete_oldest_received_message on; } Thursday, March 11, 2010
  • 22. Diagram with storage BACK-END PROCESS 1. HTTP POST 4. MESSAGE Publisher endpoint 2. POST BODY IS RETRIEVED IS QUEUED FROM QUEUE NGINX Queue BY CHANNEL ID BY CHANNEL ID Subscriber endpoint 5. RESPONSE IS 3. HTTP GET DATA FROM QUEUE End User Thursday, March 11, 2010
  • 23. Code it up. Thursday, March 11, 2010
  • 24. Client-side Gotchas ★ Javascript blocking ★ Put it in an iframe ★ Per domain connection limit ★ use subdomain, with JSONP Thursday, March 11, 2010
  • 25. Server-side Gotchas ★ “Too many open connections” ★ Reduce worker_connections to less than ulimit -n ★ Increase worker_processes to give you enough total connection to serve your users ★ Ours: worker_processes 24 worker_connections 960 Thursday, March 11, 2010
  • 26. Testing ★ Fake Publisher for in-memory cucumber scenarios ★ Run selenium scenarios through NGINX to incorporate actual push module behavior Thursday, March 11, 2010
  • 27. NGINX Configuration Management ★Template it ★Version it ★Automate it Thursday, March 11, 2010
  • 28. The Future ★ Multiplexing: subscribe to more than one channel ★ Use Redis as a message store ★ Convention-based approach for raising javascript events Thursday, March 11, 2010