messaging for real-time webapps

12
WebSockets Messaging For Real-time Web Applications. Tiju Titus John Oct 21, 2016

Upload: tiju-john

Post on 09-Jan-2017

33 views

Category:

Software


3 download

TRANSCRIPT

Page 1: Messaging for Real-time WebApps

WebSocketsMessaging For Real-time Web Applications.Tiju Titus JohnOct 21, 2016

Page 2: Messaging for Real-time WebApps

Agenda

Real-time web applications HTTP Challenges WebSocket

Design Considerations Tooling Testing

Alternate Considerations Summary Q&A

Page 3: Messaging for Real-time WebApps

Real-time Web Applications Timely nature to the data /event Timely nature to the user experience Bit-Directional Message

Peer-2-Peer Users to Systems

Asynchronous Frequent and Chatty

Examples• Web Telephony • Web Conferencing • Collaborative Rooms / Channels• IM / Chats / • Games • Real-time Dashboards

Page 4: Messaging for Real-time WebApps

HTTP wasn’t enough! Request-Response High amount of data in Headers Http 1.1 Keep Alive provide persistent connections. One Request at a Time HTTP Pipelining (HOL

Blocking – problem) Bi-directional approaches

Call back URLS (Works in server to server integration with limitations)

Polling and Long Polling Http Streaming SSE – Server Sent Events

Page 5: Messaging for Real-time WebApps

Http Upgrade - WebSockets

RFC6455 – Dec 2011 Allows full duplex communication. Wide support of tools and browsers in short time. ws:// and wss:// Post handshake is made each party can send message

as frames W3C WebSocket API Support Binary and Text Data

GET /chat HTTP/1.1Host: server.example.comUpgrade: websocketConnection: UpgradeSec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==Origin: http://example.comSec-WebSocket-Version: 13

HTTP/1.1 101 Switching ProtocolsUpgrade: websocketConnection: UpgradeSec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=

Page 6: Messaging for Real-time WebApps

Design Considerations Use Higher abstraction API’s

Socket.io SockJS

SDK vs Messages JS SDK (Twilio) (Good only browser clients) WebSocket Message API (Slack) – Interface definition's are bit tricky.

Message Reliability – Application need to built it. Only a Delivery Mechanism – No Reliable delivery At-most-once.

Using Multiple WS Channels. Big messages can delay other events as messages are delivered in order.

Subscribe to only necessary data. Non Functional Aspects.

Authentication / Authorization / Message-Auditing Webserver logs may not work.

Page 7: Messaging for Real-time WebApps

Tool Support

Chrome Developer console WebSocket Monitor – Firefox add-ons Non – Blocking io based libs Message bus Gateways

Spring STOMP broker Database Gateways Caching and CDN’s

Page 8: Messaging for Real-time WebApps

Testing Challenges

Lack of support of the shelf testing tools. Use Asynchronous Testing Framework

Mocha / should.js Perf Test – Jmeter Websocket sampler

Page 9: Messaging for Real-time WebApps

REST Replacement?

Non Real-time apps and services REST or Web Service Standardized / Templated frameworks

Use mix of Both REST & Web Socket Non real-time / stateless with REST Real-time aspects with Web Sockets Scale the real-time and non-real-time services separately and differently.

Page 10: Messaging for Real-time WebApps

Server side Integrations ?

Using as an integration Framework between services. Not an Ideal one due lack of reliability Message bus / Message Brokers might be best. Can use to traverse via firewall ( Can use it as Message Bus gateways)

Page 11: Messaging for Real-time WebApps

Similar Technologies

HTTP 2 Server Push Send multiple Response for

single Request Good for sending images/CSS/JS

WebRTC Focus on A/V, but also has data

channel Focus on P2P, but one peer be a

server. Data Streams are SCTP NAT and Firewall problems Good for rich content streams Many WebRTC solutions uses

WebSockets for signaling.

Page 12: Messaging for Real-time WebApps

Summary Technology for Real-time web applications. Not a replacement for REST / Web Services Not ideal for service integrations.