SlideShare uma empresa Scribd logo
1 de 49
Building Next Generation
Real-Time Web Applications
- Naresh Chintalcheru
Real-Time
● What are Real-Time Web Apps ?
● HTTP Half-Duplex to Full-Duplex WebSocket (WS) Protocol
● HTTP 1.1 keep-alive-mechanism
● “Hacks” such as AJAX, Long Polling & Comet used to simulate real-time
● Introduction to WebSockets
● How WebSocket Protocol works ?
● HTTP Idempotent Methods
● WebSockets & RESTful Web Services
● HTTP Session Vs WebSocket Session
● Server-Push using WebSockets
● WebSocket Performance
● WebSocket Security
● JSR-356 Java WebSocket APIs
● Spring Framework 4.0 support for WebSocket & SockJS
Asynchronous
● Intro to Asynchronous Applications
● What is Non-Blocking I/O ?
● Problem spanning Threads in JEE App Servers
● Async support in Servlets 3.0
● Asynchronous Session EJB 3.1
● Asynchronous Beans in Spring Framework
Event-Driven
● What are Event-Driven Apps ?
● node.js : Server-side Javascript
● Vert.x : Event-Driven Java framework
Real-Time
What are Real-Time Web Applications ?
What are Real-Time Web Apps ?
The real-time web enables users to receive information as
soon as it is published.
Bi-directional two-way communication between users &
system
Both Pull & Push based systems.
Real-Time Web Apps Examples
The Real-Time Web application examples.
● Gmail
● ESPN Sports
● Gotomeetings
● Netflix (Perfect disaster recovery app )
Problems with HTTP
HTTP is the fundamental web protocol and problems with
HTTP are ......
● One-way
● request/response
● stateless
● Half-Duplex protocol
Real-time example
HTTP 1.1 keep-alive
HTTP 1.1 keep-alive-mechanism or persistent connection
Connection: Keep-Alive
Keep-Alive: timeout=10, max=5
● A connection that lasts beyond the current
request/response transaction.
● Client perform multiple requests without the overhead of
connection tear-down and set-up between each request.
● Fundamental web communication change.
Real-Time "Hacks"
With HTTP 1.1 keep-alive connections real-time "hacks" or
"simulations"
● Long Polling
● AJAX (XMLHTTPRequest & InnerHTML)
● HTTP Streaming
● Adobe Flash "RTMP Protocol"
● Apache COMET (Gmails GTalk)
AJAX request
How AJAX XMLHTTPRequest is different than regular HTTP
Request
window.open()
● HTTP Request browser will stop or hang for the server
response.
xmlhttp.open()
● With AJAX request is Async, the JavaScript does not have
to wait for the server response, but can instead execute
other scripts and respond to user events while waiting for
server response. Deal with the response when the
Problems with "Hacks"
Problem with real-time simulations
● HTTP Web Server timeouts, Proxy Server timeouts
● Too many connections
● Too much overhead
● Work around but not a native solution
HTTP Protocol is Still Not Real-time
HTTP 1.1 keep-alive-mechanism
has persistent connections ......
But not ..........
Full-Duplex Communication ...
Duplex Communication
What are Full Duplex Communication ?
Duplex Communication
What are Full-Duplex Communication ?
Allows communication in both directions and happens
simultaneously.
-Two lane road
-Telephone Lines
-LAN
-Mobile Networks
-Cable Networks
-Echo Cancellation issues
Duplex Communication
HTTP is a Half-Duplex Protocol
-Walkie-Talkie ("Over" command)
-One lane road with traffic controller at each end (Traffic flows
in both but only directions at a time)
Duplex Communication Quiz
1. TCP Protocol is a Full Duplex ?
2. Database Connection Full Duplex ?
3. Middleware MQ/JMS Connections ?
Duplex Communication Quiz
Difference Keep-alive & Full-Duplex
● A Keep Alive HTTP header since HTTP 1.0, which is used
to indicate a HTTP client would like to maintain a persistent
connection with HTTP server.
● The main objects is to eliminate the needs for opening TCP
connection for each HTTP request. However, while there is
a persistent connection open, the protocol for
communication between client and server is still following
the basic HTTP request/response pattern
● Full-duplex connection Server side can Push Data to
client and client should be expected to process data from
server side
Real-Time Web
Real-Time web applications needs two-way bi-directional and
Full Duplex communication.
So upgrade HTTP Protocol ?
Upgrade HTTP Protocol
Upgrade HTTP Protocol to Full Duplex Protocol
RFC6455 WebSocket Protocol
W3C standard on Dec 2011
WebSocket Protocol
What is WebSocket ?
WebSocket Protocol
● WebSocket is a Full Duplex Web Protocol
● Two-way messaging over single connection
● It is not a HTTP protocol
● Depends on HTTP Protocol for the initial bootstrap and
afterwards uses TCP Protocol
● Websocket differs from TCP in that it enables a stream of
messages instead of a stream of bytes.
WebSocket Protocol
● HTTP://server.com , WS://server.com
● HTTPS://server.com, WSS://server.com (Secured)
● Extremely Low-overhead
Real-Time App design
State Farm ADA - JEE Application Deployment tool
● ADA Current way
● ADA with "Hacks" long polling
● ADA with WebSocket
Form based Apps
● ADA is not a revenue generating application
● What about Insurance Quote ?
● What about Insurance Claims ?
WebSocket Applications
● Current web applications are "Form based" applications
targeting simple or happy path of the Business Process.
● Extending the scope of "Functional Requirements" to
capture the complete user experience (Customer
Collaboration)
● In the future many applications will be using WebSockets
WebSocket Performance
● Each HTTP Request/Response (header+body) have
minimum of 871 Bytes overhead.
● WebSocket frames has 2 Bytes of overhead
● 1000 HTTP Clients polling a second = 6.6Mbps Network
throughput
● 1000 WebSocket Clients receiving messages (1 second) =
0.015Mbps Network throughput
www.websocket.org
WebSocket Performance
WebSocket Performance
● Web Sockets can provide a 500:1 or depending on the size
of the HTTP headers or even a 1000:1 reduction in
unnecessary HTTP header traffic
● Minimum of 3:1 reduction in latency
● Significantly improves Network throughput and Request
latency www.websocket.org
WebSocket Fundamentals
How WebSocket Protocol works ?
WebSocket Handshake Request
WebSocket Handshake Request: To establish a WebSocket
connection, the client sends a WebSocket handshake request
ws://webserver.com/home
GET /mychat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Protocol: chat
Sec-WebSocket-Version: 13
Origin: http://example.com
WebSocket Handshake Response
WebSocket Server Response: Server WebSocket handshake
response
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
Sec-WebSocket-Protocol: chat
WebSocket Handshake
● The handshake resembles HTTP so that servers can
handle HTTP connections as well as WebSocket
connections on the same port.
● Once the connection is established, the client and server
can send WebSocket data or text frames back and forth in
full-duplex mode.
● The data is minimally framed, with a small header followed
by payload. WebSocket transmissions are described as
"messages"
WebSocket Extensions
● With extensions to the protocol, this can also be used for
multiplexing several streams simultaneously (for instance
to avoid monopolizing use of a socket for a single large
payload).
WebSocket Security
Same SSL/TLS based Security
WebSocket Applications
● Trading [Stocks, Biding Apps ebay.com]
● Chat [Gmail]
● Games
● Collaboration
● Dashboard Reports
● Visualization
WebSocket Applications
● Current web applications are "Form based" applications
targeting simple or happy path of the Business Process.
● Extending the scope of "Functional Requirements" to
capture the complete user experience (Customer
Collaboration)
● In the future many applications will be using WebSockets
WebSocket Java API
● JSR-356/JEE 7 Java WebSocket Annotation based API
javax.websocket.*
● Server Endpoint
@ServerEndpoint("/hello")
public class MyEndpoint { }
● Client Endpoint
@ClientEndpoint
public class MyClientEndpoint {}
WebSocket Java API
● Connection Open
@OnOpen
public void myOnOpen (Session session) { }
● On Message
@OnMessage
public String myOnMessage (String txt) { }
● Connection Close
@OnClose
public void myOnClose (CloseReason reason) { }
WebSocket Java API
● Zero or more string parameters annotated with
@PathParam, referring to path parameters on the endpoint
path
● Java WebSocket API provides encoders/decoders to use
custom Java object messages in the OnMessage()
● A javax.websocket.CloseReason parameter describing the
reason for closing the WebSocket, for example, normal
closure, protocol error, overloaded service, and so on
WebSocket Session vs HTTPSession
● WebSocket Session is closed after connection closes.
HTTPSession is destroyed based on server timeout
setting.
● The javax.websocket.Session parameter. Note that this
parameter cannot be used once the WebSocket is really
closed, which happens after the @OnClose annotated
method returns.
WebSocket Challenges
● RESTFul web services depend on the HTTP Methods such
as GET/POST but WebSocket does not have such
methods.
● HTTP Proxy Servers are used to monitor or close
connections, content caching, filtering and designed for
HTTP-based document transfer. Not for long-lived
connections
● Wireless connections, Server connections and Client
connections many fade. Handling lost connections.
● Frequent Server Sockets/Threads open & close. Max
64,000 Sockets per machine.
Spring Framework
● Spring Framework 4.0 supports WebSocket protocol.
● If browser does not support WebSocket the Spring
framework uses SockJS library to emulate the WebSockets
in the browsers.
Future of Web Protocol
● Google SPDY/HTTP 2.0
● WebRTC for peer-to-peer communication
● Installable Web Apps (App Store for Web Apps ?)
Google SPDY & WebRTC
● Google proposed Web Network protocol SPDY. Might be
part of HTTP 2.0
● Primary goal is to reduce Web page load latency. Achieved
through compression, multiplexing, and prioritization
● WebRTC is W3Cs peer-to-peer communication Protocol.
Google SPDY & WebRTC
Installable Web Application
● With low latency and improved browser functionality the
new generation of Javascript, HTML & CSS based
"Installable Web Application" similar to App Store are
emerging.
● Google Chrome Web Store
https://chrome.google.com/webstore/category/apps
● Firefox Marketplace
https://marketplace.firefox.com/developers/
Question and Answers
Questions ?????
Email Feedback Appreciated

Mais conteúdo relacionado

Mais procurados

WEB SOCKET 應用
WEB SOCKET 應用WEB SOCKET 應用
WEB SOCKET 應用Jerromy Lee
 
Large scale web socket system with AWS and Web socket
Large scale web socket system with AWS and Web socketLarge scale web socket system with AWS and Web socket
Large scale web socket system with AWS and Web socketLe Kien Truc
 
HTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebHTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebPeter Lubbers
 
Introduction to WebSockets
Introduction to WebSocketsIntroduction to WebSockets
Introduction to WebSocketsGunnar Hillert
 
vlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets Presentationvlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets PresentationVolodymyr Lavrynovych
 
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Alex Kavanagh
 
Using Websockets with Play!
Using Websockets with Play!Using Websockets with Play!
Using Websockets with Play!Andrew Conner
 
HTML5 WebSocket Introduction
HTML5 WebSocket IntroductionHTML5 WebSocket Introduction
HTML5 WebSocket IntroductionMarcelo Jabali
 
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)Peter Lubbers
 
Websockets on the JVM: Atmosphere to the rescue!
Websockets on the JVM: Atmosphere to the rescue!Websockets on the JVM: Atmosphere to the rescue!
Websockets on the JVM: Atmosphere to the rescue!jfarcand
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersWebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersViktor Gamov
 
Camelone-2012 HTML5 WebSocket ActiveMQ/Camel
Camelone-2012 HTML5 WebSocket ActiveMQ/CamelCamelone-2012 HTML5 WebSocket ActiveMQ/Camel
Camelone-2012 HTML5 WebSocket ActiveMQ/CamelCharles Moulliard
 
Consuming ASP.NET Web API with WebSockets
Consuming ASP.NET Web API with WebSocketsConsuming ASP.NET Web API with WebSockets
Consuming ASP.NET Web API with WebSocketsMaayan Glikser
 
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)Ericom Software
 
Using WebSockets with ColdFusion
Using WebSockets with ColdFusionUsing WebSockets with ColdFusion
Using WebSockets with ColdFusioncfjedimaster
 
Websockets at tossug
Websockets at tossugWebsockets at tossug
Websockets at tossugclkao
 

Mais procurados (20)

WEB SOCKET 應用
WEB SOCKET 應用WEB SOCKET 應用
WEB SOCKET 應用
 
Ws
WsWs
Ws
 
WebSockets with Spring 4
WebSockets with Spring 4WebSockets with Spring 4
WebSockets with Spring 4
 
Large scale web socket system with AWS and Web socket
Large scale web socket system with AWS and Web socketLarge scale web socket system with AWS and Web socket
Large scale web socket system with AWS and Web socket
 
HTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebHTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the Web
 
Php push notifications
Php push notificationsPhp push notifications
Php push notifications
 
Introduction to WebSockets
Introduction to WebSocketsIntroduction to WebSockets
Introduction to WebSockets
 
Intro to WebSockets
Intro to WebSocketsIntro to WebSockets
Intro to WebSockets
 
vlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets Presentationvlavrynovych - WebSockets Presentation
vlavrynovych - WebSockets Presentation
 
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3
 
Using Websockets with Play!
Using Websockets with Play!Using Websockets with Play!
Using Websockets with Play!
 
HTML5 WebSocket Introduction
HTML5 WebSocket IntroductionHTML5 WebSocket Introduction
HTML5 WebSocket Introduction
 
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
 
Websockets on the JVM: Atmosphere to the rescue!
Websockets on the JVM: Atmosphere to the rescue!Websockets on the JVM: Atmosphere to the rescue!
Websockets on the JVM: Atmosphere to the rescue!
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersWebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
 
Camelone-2012 HTML5 WebSocket ActiveMQ/Camel
Camelone-2012 HTML5 WebSocket ActiveMQ/CamelCamelone-2012 HTML5 WebSocket ActiveMQ/Camel
Camelone-2012 HTML5 WebSocket ActiveMQ/Camel
 
Consuming ASP.NET Web API with WebSockets
Consuming ASP.NET Web API with WebSocketsConsuming ASP.NET Web API with WebSockets
Consuming ASP.NET Web API with WebSockets
 
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
 
Using WebSockets with ColdFusion
Using WebSockets with ColdFusionUsing WebSockets with ColdFusion
Using WebSockets with ColdFusion
 
Websockets at tossug
Websockets at tossugWebsockets at tossug
Websockets at tossug
 

Destaque

IoT and WebRTC
IoT and WebRTCIoT and WebRTC
IoT and WebRTCArin Sime
 
Introduction and overview ArangoDB query language AQL
Introduction and overview ArangoDB query language AQLIntroduction and overview ArangoDB query language AQL
Introduction and overview ArangoDB query language AQLArangoDB Database
 
Intro to Graph Databases Using Tinkerpop, TitanDB, and Gremlin
Intro to Graph Databases Using Tinkerpop, TitanDB, and GremlinIntro to Graph Databases Using Tinkerpop, TitanDB, and Gremlin
Intro to Graph Databases Using Tinkerpop, TitanDB, and GremlinCaleb Jones
 
Building a Next Generation Website
Building a Next Generation WebsiteBuilding a Next Generation Website
Building a Next Generation WebsiteRailslove
 
ItCamp2012-Real-Time-Web-Web-Sockets-Windows 8- Florin-Cardasim
ItCamp2012-Real-Time-Web-Web-Sockets-Windows 8- Florin-CardasimItCamp2012-Real-Time-Web-Web-Sockets-Windows 8- Florin-Cardasim
ItCamp2012-Real-Time-Web-Web-Sockets-Windows 8- Florin-CardasimFlorin Cardasim
 
Servlet Async I/O Proposal (NIO.2)
Servlet Async I/O Proposal (NIO.2)Servlet Async I/O Proposal (NIO.2)
Servlet Async I/O Proposal (NIO.2)jfarcand
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed storeAnirban Sen Chowdhary
 
Angular mobile angular_u
Angular mobile angular_uAngular mobile angular_u
Angular mobile angular_uDoris Chen
 
Developing Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax PushDeveloping Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax PushDoris Chen
 
V2 peter-lubbers-sf-jug-websocket
V2 peter-lubbers-sf-jug-websocketV2 peter-lubbers-sf-jug-websocket
V2 peter-lubbers-sf-jug-websocketbrent bucci
 
Asynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time MessagingAsynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time MessagingSteve Rhoades
 
WebRTC applications for IoT
WebRTC applications for IoTWebRTC applications for IoT
WebRTC applications for IoTIvelin Ivanov
 
WebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST MicroserviceWebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST MicroserviceRick Hightower
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Arun Gupta
 
Real Time Recommendations Using WebSockets and Redis - Ninad Divadkar, Inuit
Real Time Recommendations Using WebSockets and Redis - Ninad Divadkar, InuitReal Time Recommendations Using WebSockets and Redis - Ninad Divadkar, Inuit
Real Time Recommendations Using WebSockets and Redis - Ninad Divadkar, InuitRedis Labs
 
From Push Technology to Real-Time Messaging and WebSockets
From Push Technology to Real-Time Messaging and WebSocketsFrom Push Technology to Real-Time Messaging and WebSockets
From Push Technology to Real-Time Messaging and WebSocketsAlessandro Alinone
 

Destaque (20)

Real time coding with jWebSocket
Real time coding with jWebSocketReal time coding with jWebSocket
Real time coding with jWebSocket
 
IoT and WebRTC
IoT and WebRTCIoT and WebRTC
IoT and WebRTC
 
Introduction and overview ArangoDB query language AQL
Introduction and overview ArangoDB query language AQLIntroduction and overview ArangoDB query language AQL
Introduction and overview ArangoDB query language AQL
 
Intro to Graph Databases Using Tinkerpop, TitanDB, and Gremlin
Intro to Graph Databases Using Tinkerpop, TitanDB, and GremlinIntro to Graph Databases Using Tinkerpop, TitanDB, and Gremlin
Intro to Graph Databases Using Tinkerpop, TitanDB, and Gremlin
 
Building a Next Generation Website
Building a Next Generation WebsiteBuilding a Next Generation Website
Building a Next Generation Website
 
ItCamp2012-Real-Time-Web-Web-Sockets-Windows 8- Florin-Cardasim
ItCamp2012-Real-Time-Web-Web-Sockets-Windows 8- Florin-CardasimItCamp2012-Real-Time-Web-Web-Sockets-Windows 8- Florin-Cardasim
ItCamp2012-Real-Time-Web-Web-Sockets-Windows 8- Florin-Cardasim
 
Servlet Async I/O Proposal (NIO.2)
Servlet Async I/O Proposal (NIO.2)Servlet Async I/O Proposal (NIO.2)
Servlet Async I/O Proposal (NIO.2)
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Angular mobile angular_u
Angular mobile angular_uAngular mobile angular_u
Angular mobile angular_u
 
Developing Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax PushDeveloping Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax Push
 
V2 peter-lubbers-sf-jug-websocket
V2 peter-lubbers-sf-jug-websocketV2 peter-lubbers-sf-jug-websocket
V2 peter-lubbers-sf-jug-websocket
 
Think async
Think asyncThink async
Think async
 
Router と WebSocket
Router と WebSocketRouter と WebSocket
Router と WebSocket
 
WebSockets and Java
WebSockets and JavaWebSockets and Java
WebSockets and Java
 
Asynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time MessagingAsynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time Messaging
 
WebRTC applications for IoT
WebRTC applications for IoTWebRTC applications for IoT
WebRTC applications for IoT
 
WebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST MicroserviceWebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST Microservice
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014
 
Real Time Recommendations Using WebSockets and Redis - Ninad Divadkar, Inuit
Real Time Recommendations Using WebSockets and Redis - Ninad Divadkar, InuitReal Time Recommendations Using WebSockets and Redis - Ninad Divadkar, Inuit
Real Time Recommendations Using WebSockets and Redis - Ninad Divadkar, Inuit
 
From Push Technology to Real-Time Messaging and WebSockets
From Push Technology to Real-Time Messaging and WebSocketsFrom Push Technology to Real-Time Messaging and WebSockets
From Push Technology to Real-Time Messaging and WebSockets
 

Semelhante a Building Real-Time Web Apps with WebSockets & Async Programming

Decoding real time web communication
Decoding real time web communicationDecoding real time web communication
Decoding real time web communicationAMiT JAiN
 
Alex carcea, radu macovei a story of how java script joined the big league
Alex carcea, radu macovei   a story of how java script joined the big leagueAlex carcea, radu macovei   a story of how java script joined the big league
Alex carcea, radu macovei a story of how java script joined the big leagueCodecamp Romania
 
Smart Gamma - Real-Time Web applications with PHP and Websocket.
Smart Gamma - Real-Time Web applications with PHP and Websocket.Smart Gamma - Real-Time Web applications with PHP and Websocket.
Smart Gamma - Real-Time Web applications with PHP and Websocket.Evgeniy Kuzmin
 
Introduction to Web Sockets
Introduction to Web SocketsIntroduction to Web Sockets
Introduction to Web SocketsJumping Bean
 
Taking a Quantum Leap with Html 5 WebSocket
Taking a Quantum Leap with Html 5 WebSocketTaking a Quantum Leap with Html 5 WebSocket
Taking a Quantum Leap with Html 5 WebSocketShahriar Hyder
 
WebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkWebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkFabio Tiriticco
 
Esc 209 paper_doin
Esc 209 paper_doinEsc 209 paper_doin
Esc 209 paper_doinJonny Doin
 
Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...
Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...
Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...Srikanth Reddy Pallerla
 
Comet / WebSocket Web Applications
Comet / WebSocket Web ApplicationsComet / WebSocket Web Applications
Comet / WebSocket Web ApplicationsCodemotion
 
.NET Conf 2022 - Networking in .NET 7
.NET Conf 2022 - Networking in .NET 7.NET Conf 2022 - Networking in .NET 7
.NET Conf 2022 - Networking in .NET 7Karel Zikmund
 
DEV301- Web Service Programming with WCF 3.5
DEV301- Web Service Programming with WCF 3.5DEV301- Web Service Programming with WCF 3.5
DEV301- Web Service Programming with WCF 3.5Eyal Vardi
 
Real-Time with Flowdock
Real-Time with FlowdockReal-Time with Flowdock
Real-Time with FlowdockFlowdock
 

Semelhante a Building Real-Time Web Apps with WebSockets & Async Programming (20)

JUG louvain websockets
JUG louvain websocketsJUG louvain websockets
JUG louvain websockets
 
Decoding real time web communication
Decoding real time web communicationDecoding real time web communication
Decoding real time web communication
 
Alex carcea, radu macovei a story of how java script joined the big league
Alex carcea, radu macovei   a story of how java script joined the big leagueAlex carcea, radu macovei   a story of how java script joined the big league
Alex carcea, radu macovei a story of how java script joined the big league
 
Websocket
WebsocketWebsocket
Websocket
 
Web-Socket
Web-SocketWeb-Socket
Web-Socket
 
Smart Gamma - Real-Time Web applications with PHP and Websocket.
Smart Gamma - Real-Time Web applications with PHP and Websocket.Smart Gamma - Real-Time Web applications with PHP and Websocket.
Smart Gamma - Real-Time Web applications with PHP and Websocket.
 
Introduction to Web Sockets
Introduction to Web SocketsIntroduction to Web Sockets
Introduction to Web Sockets
 
ClientServer Websocket.pptx
ClientServer Websocket.pptxClientServer Websocket.pptx
ClientServer Websocket.pptx
 
Taking a Quantum Leap with Html 5 WebSocket
Taking a Quantum Leap with Html 5 WebSocketTaking a Quantum Leap with Html 5 WebSocket
Taking a Quantum Leap with Html 5 WebSocket
 
The HTML5 WebSocket API
The HTML5 WebSocket APIThe HTML5 WebSocket API
The HTML5 WebSocket API
 
Websocket
WebsocketWebsocket
Websocket
 
WebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkWebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! Framework
 
Websocket
WebsocketWebsocket
Websocket
 
Esc 209 paper_doin
Esc 209 paper_doinEsc 209 paper_doin
Esc 209 paper_doin
 
Servlet by Rj
Servlet by RjServlet by Rj
Servlet by Rj
 
Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...
Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...
Polling Techniques, Ajax, protocol Switching from Http to Websocket standard ...
 
Comet / WebSocket Web Applications
Comet / WebSocket Web ApplicationsComet / WebSocket Web Applications
Comet / WebSocket Web Applications
 
.NET Conf 2022 - Networking in .NET 7
.NET Conf 2022 - Networking in .NET 7.NET Conf 2022 - Networking in .NET 7
.NET Conf 2022 - Networking in .NET 7
 
DEV301- Web Service Programming with WCF 3.5
DEV301- Web Service Programming with WCF 3.5DEV301- Web Service Programming with WCF 3.5
DEV301- Web Service Programming with WCF 3.5
 
Real-Time with Flowdock
Real-Time with FlowdockReal-Time with Flowdock
Real-Time with Flowdock
 

Mais de Naresh Chintalcheru

Bimodal IT for Speed and Innovation
Bimodal IT for Speed and InnovationBimodal IT for Speed and Innovation
Bimodal IT for Speed and InnovationNaresh Chintalcheru
 
Introduction to Node.js Platform
Introduction to Node.js PlatformIntroduction to Node.js Platform
Introduction to Node.js PlatformNaresh Chintalcheru
 
3rd Generation Web Application Platforms
3rd Generation Web Application Platforms3rd Generation Web Application Platforms
3rd Generation Web Application PlatformsNaresh Chintalcheru
 
Asynchronous Processing in Java/JEE/Spring
Asynchronous Processing in Java/JEE/SpringAsynchronous Processing in Java/JEE/Spring
Asynchronous Processing in Java/JEE/SpringNaresh Chintalcheru
 
Problems opening SOA to the Online Web Applications
Problems opening SOA to the Online Web ApplicationsProblems opening SOA to the Online Web Applications
Problems opening SOA to the Online Web ApplicationsNaresh Chintalcheru
 
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...Naresh Chintalcheru
 
Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code ExamplesNaresh Chintalcheru
 
Design & Develop Batch Applications in Java/JEE
Design & Develop Batch Applications in Java/JEEDesign & Develop Batch Applications in Java/JEE
Design & Develop Batch Applications in Java/JEENaresh Chintalcheru
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using SeleniumNaresh Chintalcheru
 
Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC Naresh Chintalcheru
 
Object-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism UnleashedObject-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism UnleashedNaresh Chintalcheru
 

Mais de Naresh Chintalcheru (16)

Cars.com Journey to AWS Cloud
Cars.com Journey to AWS CloudCars.com Journey to AWS Cloud
Cars.com Journey to AWS Cloud
 
Bimodal IT for Speed and Innovation
Bimodal IT for Speed and InnovationBimodal IT for Speed and Innovation
Bimodal IT for Speed and Innovation
 
Reactive systems
Reactive systemsReactive systems
Reactive systems
 
Introduction to Node.js Platform
Introduction to Node.js PlatformIntroduction to Node.js Platform
Introduction to Node.js Platform
 
3rd Generation Web Application Platforms
3rd Generation Web Application Platforms3rd Generation Web Application Platforms
3rd Generation Web Application Platforms
 
Asynchronous Processing in Java/JEE/Spring
Asynchronous Processing in Java/JEE/SpringAsynchronous Processing in Java/JEE/Spring
Asynchronous Processing in Java/JEE/Spring
 
Problems opening SOA to the Online Web Applications
Problems opening SOA to the Online Web ApplicationsProblems opening SOA to the Online Web Applications
Problems opening SOA to the Online Web Applications
 
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...
Lie Cheat & Steal to build Hyper-Fast Applications using Event-Driven Archite...
 
Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code Examples
 
Big Trends in Big Data
Big Trends in Big DataBig Trends in Big Data
Big Trends in Big Data
 
Design & Develop Batch Applications in Java/JEE
Design & Develop Batch Applications in Java/JEEDesign & Develop Batch Applications in Java/JEE
Design & Develop Batch Applications in Java/JEE
 
Mule ESB Fundamentals
Mule ESB FundamentalsMule ESB Fundamentals
Mule ESB Fundamentals
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC Design & Development of Web Applications using SpringMVC
Design & Development of Web Applications using SpringMVC
 
Android Platform Architecture
Android Platform ArchitectureAndroid Platform Architecture
Android Platform Architecture
 
Object-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism UnleashedObject-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism Unleashed
 

Último

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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
 

Último (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
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...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 

Building Real-Time Web Apps with WebSockets & Async Programming

  • 1. Building Next Generation Real-Time Web Applications - Naresh Chintalcheru
  • 2. Real-Time ● What are Real-Time Web Apps ? ● HTTP Half-Duplex to Full-Duplex WebSocket (WS) Protocol ● HTTP 1.1 keep-alive-mechanism ● “Hacks” such as AJAX, Long Polling & Comet used to simulate real-time ● Introduction to WebSockets ● How WebSocket Protocol works ? ● HTTP Idempotent Methods ● WebSockets & RESTful Web Services ● HTTP Session Vs WebSocket Session ● Server-Push using WebSockets ● WebSocket Performance ● WebSocket Security ● JSR-356 Java WebSocket APIs ● Spring Framework 4.0 support for WebSocket & SockJS
  • 3. Asynchronous ● Intro to Asynchronous Applications ● What is Non-Blocking I/O ? ● Problem spanning Threads in JEE App Servers ● Async support in Servlets 3.0 ● Asynchronous Session EJB 3.1 ● Asynchronous Beans in Spring Framework
  • 4. Event-Driven ● What are Event-Driven Apps ? ● node.js : Server-side Javascript ● Vert.x : Event-Driven Java framework
  • 5. Real-Time What are Real-Time Web Applications ?
  • 6. What are Real-Time Web Apps ? The real-time web enables users to receive information as soon as it is published. Bi-directional two-way communication between users & system Both Pull & Push based systems.
  • 7. Real-Time Web Apps Examples The Real-Time Web application examples. ● Gmail ● ESPN Sports ● Gotomeetings ● Netflix (Perfect disaster recovery app )
  • 8. Problems with HTTP HTTP is the fundamental web protocol and problems with HTTP are ...... ● One-way ● request/response ● stateless ● Half-Duplex protocol Real-time example
  • 9. HTTP 1.1 keep-alive HTTP 1.1 keep-alive-mechanism or persistent connection Connection: Keep-Alive Keep-Alive: timeout=10, max=5 ● A connection that lasts beyond the current request/response transaction. ● Client perform multiple requests without the overhead of connection tear-down and set-up between each request. ● Fundamental web communication change.
  • 10. Real-Time "Hacks" With HTTP 1.1 keep-alive connections real-time "hacks" or "simulations" ● Long Polling ● AJAX (XMLHTTPRequest & InnerHTML) ● HTTP Streaming ● Adobe Flash "RTMP Protocol" ● Apache COMET (Gmails GTalk)
  • 11. AJAX request How AJAX XMLHTTPRequest is different than regular HTTP Request window.open() ● HTTP Request browser will stop or hang for the server response. xmlhttp.open() ● With AJAX request is Async, the JavaScript does not have to wait for the server response, but can instead execute other scripts and respond to user events while waiting for server response. Deal with the response when the
  • 12. Problems with "Hacks" Problem with real-time simulations ● HTTP Web Server timeouts, Proxy Server timeouts ● Too many connections ● Too much overhead ● Work around but not a native solution
  • 13. HTTP Protocol is Still Not Real-time HTTP 1.1 keep-alive-mechanism has persistent connections ...... But not .......... Full-Duplex Communication ...
  • 14. Duplex Communication What are Full Duplex Communication ?
  • 15. Duplex Communication What are Full-Duplex Communication ? Allows communication in both directions and happens simultaneously. -Two lane road -Telephone Lines -LAN -Mobile Networks -Cable Networks -Echo Cancellation issues
  • 16. Duplex Communication HTTP is a Half-Duplex Protocol -Walkie-Talkie ("Over" command) -One lane road with traffic controller at each end (Traffic flows in both but only directions at a time)
  • 17. Duplex Communication Quiz 1. TCP Protocol is a Full Duplex ? 2. Database Connection Full Duplex ? 3. Middleware MQ/JMS Connections ?
  • 19. Difference Keep-alive & Full-Duplex ● A Keep Alive HTTP header since HTTP 1.0, which is used to indicate a HTTP client would like to maintain a persistent connection with HTTP server. ● The main objects is to eliminate the needs for opening TCP connection for each HTTP request. However, while there is a persistent connection open, the protocol for communication between client and server is still following the basic HTTP request/response pattern ● Full-duplex connection Server side can Push Data to client and client should be expected to process data from server side
  • 20. Real-Time Web Real-Time web applications needs two-way bi-directional and Full Duplex communication. So upgrade HTTP Protocol ?
  • 21. Upgrade HTTP Protocol Upgrade HTTP Protocol to Full Duplex Protocol RFC6455 WebSocket Protocol W3C standard on Dec 2011
  • 23. WebSocket Protocol ● WebSocket is a Full Duplex Web Protocol ● Two-way messaging over single connection ● It is not a HTTP protocol ● Depends on HTTP Protocol for the initial bootstrap and afterwards uses TCP Protocol ● Websocket differs from TCP in that it enables a stream of messages instead of a stream of bytes.
  • 24. WebSocket Protocol ● HTTP://server.com , WS://server.com ● HTTPS://server.com, WSS://server.com (Secured) ● Extremely Low-overhead
  • 25. Real-Time App design State Farm ADA - JEE Application Deployment tool ● ADA Current way ● ADA with "Hacks" long polling ● ADA with WebSocket
  • 26. Form based Apps ● ADA is not a revenue generating application ● What about Insurance Quote ? ● What about Insurance Claims ?
  • 27. WebSocket Applications ● Current web applications are "Form based" applications targeting simple or happy path of the Business Process. ● Extending the scope of "Functional Requirements" to capture the complete user experience (Customer Collaboration) ● In the future many applications will be using WebSockets
  • 28. WebSocket Performance ● Each HTTP Request/Response (header+body) have minimum of 871 Bytes overhead. ● WebSocket frames has 2 Bytes of overhead ● 1000 HTTP Clients polling a second = 6.6Mbps Network throughput ● 1000 WebSocket Clients receiving messages (1 second) = 0.015Mbps Network throughput www.websocket.org
  • 30. WebSocket Performance ● Web Sockets can provide a 500:1 or depending on the size of the HTTP headers or even a 1000:1 reduction in unnecessary HTTP header traffic ● Minimum of 3:1 reduction in latency ● Significantly improves Network throughput and Request latency www.websocket.org
  • 32. WebSocket Handshake Request WebSocket Handshake Request: To establish a WebSocket connection, the client sends a WebSocket handshake request ws://webserver.com/home GET /mychat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw== Sec-WebSocket-Protocol: chat Sec-WebSocket-Version: 13 Origin: http://example.com
  • 33. WebSocket Handshake Response WebSocket Server Response: Server WebSocket handshake response HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk= Sec-WebSocket-Protocol: chat
  • 34. WebSocket Handshake ● The handshake resembles HTTP so that servers can handle HTTP connections as well as WebSocket connections on the same port. ● Once the connection is established, the client and server can send WebSocket data or text frames back and forth in full-duplex mode. ● The data is minimally framed, with a small header followed by payload. WebSocket transmissions are described as "messages"
  • 35. WebSocket Extensions ● With extensions to the protocol, this can also be used for multiplexing several streams simultaneously (for instance to avoid monopolizing use of a socket for a single large payload).
  • 37. WebSocket Applications ● Trading [Stocks, Biding Apps ebay.com] ● Chat [Gmail] ● Games ● Collaboration ● Dashboard Reports ● Visualization
  • 38. WebSocket Applications ● Current web applications are "Form based" applications targeting simple or happy path of the Business Process. ● Extending the scope of "Functional Requirements" to capture the complete user experience (Customer Collaboration) ● In the future many applications will be using WebSockets
  • 39. WebSocket Java API ● JSR-356/JEE 7 Java WebSocket Annotation based API javax.websocket.* ● Server Endpoint @ServerEndpoint("/hello") public class MyEndpoint { } ● Client Endpoint @ClientEndpoint public class MyClientEndpoint {}
  • 40. WebSocket Java API ● Connection Open @OnOpen public void myOnOpen (Session session) { } ● On Message @OnMessage public String myOnMessage (String txt) { } ● Connection Close @OnClose public void myOnClose (CloseReason reason) { }
  • 41. WebSocket Java API ● Zero or more string parameters annotated with @PathParam, referring to path parameters on the endpoint path ● Java WebSocket API provides encoders/decoders to use custom Java object messages in the OnMessage() ● A javax.websocket.CloseReason parameter describing the reason for closing the WebSocket, for example, normal closure, protocol error, overloaded service, and so on
  • 42. WebSocket Session vs HTTPSession ● WebSocket Session is closed after connection closes. HTTPSession is destroyed based on server timeout setting. ● The javax.websocket.Session parameter. Note that this parameter cannot be used once the WebSocket is really closed, which happens after the @OnClose annotated method returns.
  • 43. WebSocket Challenges ● RESTFul web services depend on the HTTP Methods such as GET/POST but WebSocket does not have such methods. ● HTTP Proxy Servers are used to monitor or close connections, content caching, filtering and designed for HTTP-based document transfer. Not for long-lived connections ● Wireless connections, Server connections and Client connections many fade. Handling lost connections. ● Frequent Server Sockets/Threads open & close. Max 64,000 Sockets per machine.
  • 44. Spring Framework ● Spring Framework 4.0 supports WebSocket protocol. ● If browser does not support WebSocket the Spring framework uses SockJS library to emulate the WebSockets in the browsers.
  • 45. Future of Web Protocol ● Google SPDY/HTTP 2.0 ● WebRTC for peer-to-peer communication ● Installable Web Apps (App Store for Web Apps ?)
  • 46. Google SPDY & WebRTC ● Google proposed Web Network protocol SPDY. Might be part of HTTP 2.0 ● Primary goal is to reduce Web page load latency. Achieved through compression, multiplexing, and prioritization ● WebRTC is W3Cs peer-to-peer communication Protocol.
  • 47. Google SPDY & WebRTC
  • 48. Installable Web Application ● With low latency and improved browser functionality the new generation of Javascript, HTML & CSS based "Installable Web Application" similar to App Store are emerging. ● Google Chrome Web Store https://chrome.google.com/webstore/category/apps ● Firefox Marketplace https://marketplace.firefox.com/developers/
  • 49. Question and Answers Questions ????? Email Feedback Appreciated