“Because as rapid as the arrival of
     networked pull media was,
     the second act - networked push
     media - is co...
Push
                                A 2010 case study with
                           the NGINX HTTP Push Module,
       ...
Who’s this guy?
                ★ VP, Engineering at weplay.com
                ★ Agilist
                ★ nyc.rb’er sinc...
What’s this talk?
              ★ The goal and the problem
              ★ A quick survey of solutions
              ★ Abo...
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 reque...
Pure push
               doesn’t exist
             on the open web

Thursday, March 11, 2010
XMPP                  WebSockets

                           Push-like
                           solutions
      Streamin...
★       Don’t close the connection after
                  sending down the page
          ★       multipart/x-mixed-repla...
XMPP
          ★       Designed for presence and messaging
          ★       Browsers don’t speak XMPP natively
          ...
★       Push data over a long held Ajax
                  request using browser-native
                  technologies
    ...
WebSockets
          ★       HTML 5
          ★       Full-duplex single socket connection
                  between brows...
XMPP               WebSockets




      Streaming               Comet
Thursday, March 11, 2010
ejabberd                       Sunshowers


                                             Rainbows!
                       ...
NGINX HTTP Push Module

                    ★      Turns NGINX into a Comet server
                    ★      “A useful to...
Basic HTTP Push
                                Relay Protocol
                           ★   Subscriber locations
       ...
Diagramming the simple case
                                                  BACK-END
                                   ...
Channel
                           Concurrency Styles

                             ★ Broadcast

                         ...
Subscriber config

             # public long‐polling endpoint
             location /rt/notifications {
               pus...
Publisher config
       # internal publish endpoint
       # (keep it private / protected)
       location /rt/publish {
  ...
Diagram with storage
                                                    BACK-END
                                        ...
Code it up.




Thursday, March 11, 2010
Client-side Gotchas
                    ★      Javascript blocking
                           ★   Put it in an iframe
    ...
Server-side Gotchas
                ★          “Too many open connections”
                      ★    Reduce worker_connec...
Testing


                    ★      Fake Publisher for in-memory
                           cucumber scenarios
          ...
NGINX Configuration
                   Management

                           ★Template   it
                           ★Ve...
The Future
                           ★   Multiplexing: subscribe
                               to more than one
        ...
Questions?




Thursday, March 11, 2010
Upcoming SlideShare
Loading in …5
×

Http Push

3,136 views

Published on

A 2010 case study with the NGINX HTTP Push Module, Ruby on Rails, and friends, by Luke Melia of Weplay

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,136
On SlideShare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
Downloads
50
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Http Push

  1. 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. 2. Push A 2010 case study with the NGINX HTTP Push Module, Ruby on Rails, and friends Luke Melia Thursday, March 11, 2010
  3. 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. 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. 5. The Goal ★ Immediate encouragement of positive on-site actions ★ “Points!” Thursday, March 11, 2010
  6. 6. +10 Thursday, March 11, 2010
  7. 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. 8. Pure push doesn’t exist on the open web Thursday, March 11, 2010
  9. 9. XMPP WebSockets Push-like solutions Streaming Comet Thursday, March 11, 2010
  10. 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. 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. 12. ★ Push data over a long held Ajax request using browser-native technologies ★ Bayeaux protocol ★ Long-polling Ajax Comet Thursday, March 11, 2010
  13. 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. 14. XMPP WebSockets Streaming Comet Thursday, March 11, 2010
  15. 15. ejabberd Sunshowers Rainbows! Servers Cramp Juggernaut NGINX HTTP Push Module Orbited Tornado Diesel Faye Thursday, March 11, 2010
  16. 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. 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. 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. 19. Channel Concurrency Styles ★ Broadcast ★ Last-in, first-out ★ First-in, last-out Thursday, March 11, 2010
  20. 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. 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. 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. 23. Code it up. Thursday, March 11, 2010
  24. 24. Client-side Gotchas ★ Javascript blocking ★ Put it in an iframe ★ Per domain connection limit ★ use subdomain, with JSONP Thursday, March 11, 2010
  25. 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. 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. 27. NGINX Configuration Management ★Template it ★Version it ★Automate it Thursday, March 11, 2010
  28. 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
  29. 29. Questions? Thursday, March 11, 2010

×