웹 푸시 구현 26th UPnL Workshop 김재찬.

Slides:



Advertisements
Similar presentations
Games, chat, and finance Toward a truly interactive web with Comet, BAM, and HMTP Emil Ong Chief Evangelist.
Advertisements

What is it? –Large Web sites that support commercial use cannot be written by hand What you’re going to learn –How a Web server and a database can be used.
1 Cleaning up the Internet Using AJAX, SOAP and Comet CS526 Mike Gerschefske Justin Gray James Yoo 02 May 2006.
Multiple Tiers in Action
Chapter 2: Application layer  2.1 Web and HTTP  2.2 FTP 2-1 Lecture 5 Application Layer.
Complaint Desk Team 8. Introduction A web based system that records grievances. A web based system that records grievances. Users can report their grievances.
5/3/2006 Mike/Justin/JYoo AJAX/SOAP/Comet 1 Cleaning up the Internet Using AJAX, SOAP and Comet CS526 Mike Gerschefske Justin Gray James Yoo 02 May 2006.
Creating your website Using Plain HTML. What is HTML? ► Web pages are authored in HyperText Markup Language (HTML) ► Plain text is marked up with tags,
Reverse AJAX and HTML5 Based Clients for Embedded Control and Monitoring Systems C Robson, C Bohm, Stockholm University or "HTML5, why should we care?"
Understanding Networks Charles Zangla. Network Models Before I can explain how connections are made from across the country, I would like to provide you.
CS 218 F 2003 Nov 3 lecture:  Streaming video/audio  Adaptive encoding (eg, layered encoding)  TCP friendliness References: r J. Padhye, V.Firoiu, D.
Lightning Talk Fred Rodriguez Aakash Juneja CPSC 473 March 16, 2012.
1 What Can HTML5 WebSocket Do For You? Sidda Eraiah Director of Management Services Kaazing Corporation.
(1) Real Time Web. (2) Request – Response How would you create: A stock price ticker? A sports game cast app? A server status app? 1. Polling 2. Long.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.

Chapter 29 World Wide Web & Browsing World Wide Web (WWW) is a distributed hypermedia (hypertext & graphics) on-line repository of information that users.
Session 7: JMS, JCA, JSF Dr. Nipat Jongsawat.
AMQP, Message Broker Babu Ram Dawadi. overview Why MOM architecture? Messaging broker like RabbitMQ in brief RabbitMQ AMQP – What is it ?
Java Message Service (JMS) Web Apps and Services.
How Web Database Architectures Work CPS181s April 8, 2003.
AJAX Use Cases for WSRP Subbu Allamaraju BEA Systems Inc WSRP F2F Meeting, May 2006.
Message Framework Topic subscribe for javascript/flex client.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
PHP and AJAX. Servers and Clients For many years we tried to move as much as possible to the server. Weak clients, poor bandwidth, browser compatibility..
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
COMPUTER NETWORKS Hwajung Lee. Image Source:
Keith Telle Lead Software Engineer Bit Wizards Behind the Magic: SignalR Demystified.
Ur/Web: A Simple Model for Programming the Web
Slide 1 What the Bayeux? Filip Hanik SpringSource Inc Keystone, Colorado, 2008.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Java Web Services Orca Knowledge Center – Web Service key concepts.
Research of Web Real-Time Communication Based on WebSocket
WebSockets and Equinox OSGi in a Servlet Container
Real-Time GIS Leveraging Stream Services
How to Give Your Sencha App
Internet of Things.
The internet Zurich Water Game
Web Technologies Computing Science Thompson Rivers University
Internet Technologies
Remote execution of long-running CGIs
Introduction to Dynamic Web Programming
WebRTC enabled multimedia conferencing and collaboration solution
CS5220 Advanced Topics in Web Programming Introduction to WebSocket
Web Development Web Servers.
Websocket Application
CS 371 Web Application Programming
Node.js Express Web Services
Subbu Allamaraju BEA Systems Inc
Some bits on how it works
Building real-time web apps with WebSockets using IIS, ASP.NET and WCF
WebSocket: Full-Duplex Solution for the Web
Building real-time web apps with HTML5 WebSockets
Web Browser server client 3-Tier Architecture Apache web server PHP
The pub-sub channels based push service…..
Pub/sub-based Web Applications
03 | Building a Backend with Socket.IO and Mongo
Building Windows 8 and Windows Azure apps
HTTP/2.
Introduction to HTML5 and WebSockets.
J2EE Lecture 13: JMS and WebSocket
BOF #2 – Introduction to PHP and MySQL
Web Technologies Computing Science Thompson Rivers University
Electronic Payment Security Technologies
Client-Server Model: Requesting a Web Page
Your computer is the client
Part II Application Layer.
[Based in part on SWE 432 and SWE 632 materials by Jeff Offutt, GMU]
Presentation transcript:

웹 푸시 구현 26th UPnL Workshop 김재찬

Push?

Why?

HTTP(1996~)

Web Browser Server Database User

Web Browser Server Database User

Web Browser Server Database User

Web Browser Server Database User

Web Browser Server Database User

Web Browser Server Database User

Push(200x~)

Web Browser1 Server Database /write User1

Web Browser1 Server Database /write User1

Web Browser1 Server Database /write User1

Web Browser1 Server Database /write User1

Web Browser1 Server Database /write User1 Web Browser2 User2

Web Browser1 Server Database /write User1 Web Browser2 User2

Web Browser1 Server Database /write User1 Web Browser2 User2 User1 wrote something!

Web Browser Server

Web Browser

Short Polling

Web Browser Server Database User

Web Browser Server Database User Do this per 30 seconds

Web Browser Server Timeline Timeline

Web Browser Server Timeline Timeline

Web Browser Server No new article Timeline Timeline

Web Browser Server New article No new article Timeline Timeline

Web Browser Server New article No new article Timeline Timeline

Web Browser Server Timeline Timeline No new article 1 new article

Web Browser Server Timeline Timeline No new article 1 new article

Web Browser Server Timeline Timeline No new article 1 new article

Web Browser Server Timeline Timeline No new article 1 new article

Web Browser Server Timeline Timeline No new article 1 new article

Web Browser Server Timeline Timeline No new article 1 new article

Web Browser Server Timeline Timeline No new article 1 new article

(function(){ var lastArticleId = 0; setInterval(function(){ $.ajax({ url: 'some_url', type: 'get', data: {'last_article_id': lastArticleId} }) .then(function(data){ data = JSON.parse(data); if(data.new_articles.length > 0){ // DO SOMETHING lastArticleId = data.new_articles[0].id; } }); }, 30000); })();

Long Polling

Web Browser1 Server Database User1

Web Browser1 Server Database User1 Web Browser2 /write User2

Web Browser1 Server Database User1 Web Browser2 /write User2

Web Browser1 Server Database User1 Web Browser2 /write User2

Web Browser1 Server Database User1 Web Browser2 /write User2

Web Browser1 Server Database User1 User2 wrote something! Web Browser2 /write User2

Web Browser Server Timeline Timeline

Web Browser Server Timeline Timeline

Web Browser Server New article Timeline Timeline

Web Browser Server new Article! New article Timeline Timeline

Web Browser Server new Article! New article Timeline Timeline

Web Browser Server Timeline Timeline new Article! New article

Web Browser Server Timeline Timeline new Article! new article!

Web Browser Server Timeline Timeline new Article! new article!

Web Browser Server Timeline Timeline new Article! new article! Connection Timeout Timeline Timeline

Web Browser Server Timeline Timeline new Article! new article! Connection Timeout Timeline Timeline

(function(){ var callback = function(data){ data = JSON.parse(data); // DO SOMETHING }; var polling_func = function(){ $.ajax({ url: 'some_url', type: 'get', } ).then(callback) .always(polling_func); polling_func(); })();

iframe stream script tag xhr

COMET

Real time push via HTTP request COMET Real time push via HTTP request

WebSocket

WebSocket WebSocket is a protocol providing full-duplex communications channels over a single TCP connection. The WebSocket protocol was standardized by the IETF as RFC 6455 in 2011, and the WebSocket API in Web IDL is being standardized by the W3C. http://en.wikipedia.org/wiki/WebSocket

(function(){ var ws = new WebSocket('ws://some_url'); ws.addEventListener('message', function(e){ // DO SOMETHING }); })();

http://caniuse.com/websockets

http://caniuse.com/websockets

Web Browser Server

Server

For Short Polling

<?php $last_article_id = $_GET['last_article_id']; $queries = mysql_fetch_array("SELECT * FROM article \ WHERE id > " . $last_article_id . "ORDER BY id \ DESC"); $result = make_result($queries); header('Content-Type: application/json'); echo json_encode($result);

For Long Polling

Web Browser1 Server Database /write User1 Web Browser2 User2

Web Browser1 Server Database /write User1 Web Browser2 User2 ???

Web Browser1 Server Session 1 Database /write User1 Web Browser2 Server Session 2 User2 ???

<?php // get last article id $last_article = mysql_query("SELECT * FROM article \ ORDER BY id DESC LIMIT 1"); $last_article_id = $last_article['id']; while(TRUE){ $queries = mysql_fetch_array("SELECT * FROM article\ WHERE id > " . $last_article_id . " ORDER BY id DESC"); if(count($query) > 0){ $result = make_result($query); header('Content-Type: application/json'); echo json_encode($result); break; } sleep(1);

<?php // get last article id $last_article = mysql_query("SELECT * FROM article \ ORDER BY id DESC LIMIT 1"); $last_article_id = $last_article['id']; while(TRUE){ $queries = mysql_fetch_array("SELECT * FROM article\ WHERE id > " . $last_article_id . " ORDER BY id DESC"); if(count($query) > 0){ $result = make_result($query); header('Content-Type: application/json'); echo json_encode($result); break; } sleep(1);

<?php // get last article id $last_article = mysql_query("SELECT * FROM article \ ORDER BY id DESC LIMIT 1"); $last_article_id = $last_article['id']; while(TRUE){ $queries = mysql_fetch_array("SELECT * FROM article\ WHERE id > " . $last_article_id . " ORDER BY id DESC"); if(count($query) > 0){ $result = make_result($query); header('Content-Type: application/json'); echo json_encode($result); break; } sleep(1); what if 2 articles in 1 second?

<?php // get last article id $last_article = mysql_query("SELECT * FROM article \ ORDER BY id DESC LIMIT 1"); $last_article_id = $last_article['id']; while(TRUE){ $queries = mysql_fetch_array("SELECT * FROM article\ WHERE id > " . $last_article_id . " ORDER BY id DESC"); if(count($query) > 0){ $result = make_result($query); header('Content-Type: application/json'); echo json_encode($result); break; } sleep(0.1);

× 10 <?php // get last article id $last_article = mysql_query("SELECT * FROM article \ ORDER BY id DESC LIMIT 1"); $last_article_id = $last_article['id']; while(TRUE){ $queries = mysql_fetch_array("SELECT * FROM article\ WHERE id > " . $last_article_id . " ORDER BY id DESC"); if(count($query) > 0){ $result = make_result($query); header('Content-Type: application/json'); echo json_encode($result); break; } sleep(0.1); × 10

Publish/Subcribe Model

Publish/Subcribe Model In software architecture, publish–subscribe is a messaging pattern where senders of messages, called publishers, do not program the messages to be sent directly to specific receivers, called subscribers. Instead, published messages are characterized into classes, without knowledge of what, if any, subscribers there may be. Similarly, subscribers express interest in one or more classes, and only receive messages that are of interest, without knowledge of what, if any, publishers there are. http://en.wikipedia.org/wiki/Publish/subscribe

Publish/Subcribe Model In software architecture, publish–subscribe is a messaging pattern where senders of messages, called publishers, do not program the messages to be sent directly to specific receivers, called subscribers. Instead, published messages are characterized into classes, without knowledge of what, if any, subscribers there may be. Similarly, subscribers express interest in one or more classes, and only receive messages that are of interest, without knowledge of what, if any, publishers there are. http://en.wikipedia.org/wiki/Publish/subscribe

Publish/Subcribe Model In software architecture, publish–subscribe is a messaging pattern where senders of messages, called publishers, do not program the messages to be sent directly to specific receivers, called subscribers. Instead, published messages are characterized into classes, without knowledge of what, if any, subscribers there may be. Similarly, subscribers express interest in one or more classes, and only receive messages that are of interest, without knowledge of what, if any, publishers there are. http://en.wikipedia.org/wiki/Publish/subscribe

Key-Value Store

Key-Value Store NoSQL

Key-Value Store NoSQL Cache Store

Key-Value Store NoSQL Cache Store Pub/Sub Model

write.php <? // DO SOMETHING // assume that $article_id, $author_name is assigned. $redis = new Redis(); $redis->connect('127.0.0.1'); $redis->publish('new_article', json_encode(array( 'article_id'=>$article_id, 'author_name' => $author_name))); $redis->close();

Subscribe.php <? function callfunc($redis, $channel, $msg){ if($channel === 'new_article'){ echo $msg; } exit; // Erase this line if you use WebSocket $redis = new Redis(); $redis->connect('127.0.0.1'); $redis->subscribe(array('new-article'), 'callback_func');

Redis PUBLISH/SUBSCRIBE Message Queue PostgreSQL’s NOFITY/LISTEN

결론 Push! Server Client Pub/Sub Model (Short) Polling WebSocket Redis PostgreSQL Not Real Time Message Queue COMET Real time Push via HTTP request (Long) Polling WebSocket