SlideShare a Scribd company logo
1 of 32
Websocket-Chat-Application
WHO AM I?
Minh Nguyen Vo Cao
tech lead @ CENT Technology
koding: minhnvc
AGENDA
1. Real-time technologies
2. Jetty Embedded
3. WebSocket with Jetty
4. Build a chat application
5. Performance
CHAT APPLICATIONS
FIRST: A STORY
On a sunny morning …
The biz girl told you …
“We need to develop a chat application
like Facebook”
REAL-TIME WEB TECHNOLOIES
Do you have any news for me?
No
Do you have any news for me?
No
Do you have any news for me?
No!!!!@#$%
AJAX POLLING
• The requested webpage executes JS which requests
to server at regular intervals (e.g. 0.5 seconds).
• The server calculates each response and sends it
back, just like normal http traffic.
Do you have any news for me?
…
…
Here you are!
“#%#$%@@!”
Anything else?
…
AJAX LONG-POLLING
• The requested webpage executes JS which requests
a file from the server.
• The server does not immediately respond with the
requested information but waits until there's new
information available.
• The client receives the new information and
immediately sends another request to the server, re-
starting the process.
Good morning!
You have new message
You have new email
Hey, What are you doing ?
HTML5 WEBSOCKETS
• The requested webpage executes JS which opens a
connection with the server.
• The server and the client can now send each other
messages when new data is available.
POLLING VS LONG-POLLING VS
WEBSOCKET
… Ajax Polling
Ajax Long-
polling
WebSocket
Browser support
Supported by the
most of currently
used browsers
Supported by the
most of currently
used browsers
IE 10+,…
(caniuse.com)
Server-loading
It repeatedly
calculates and
responses a lot of
requests from
clients.
Takes little of
CPU resources,
but creates idle
processes.
The best possible
solution. No
loops, only take
CPU/memory
per client action.
Client-loading
Natively
implemented in
the browser
Natively
implemented in
the browser
Natively
implemented in
the browser
Timeliness
Can adjust the
interval settings.
Near real-time True real-time
JETTY EMBEDDED
• Jetty provides a Web server and javax.servlet
container plus support for WebSocket.
• Standalone
WHY ??
Lightweight, mini,
pluggable, …
And JAV is awesome!
Sorry, JAVA
CREATE A SERVER
Don't deploy your application in
Jetty, deploy Jetty in your
application
Your app
HTTP HTTP …
WS WS …
java –jar myapp.jar
WEBSOCKET WITH JETTY
• Require Java 7
WEBSOCKET ANNOTATIONS
@WebSocket
@OnWebSocketConnect
@OnWebSocketClose
@OnWebSocketMessage
Chat Application
HTTP/ JSON API
WS
for Global Chat
WS
for Private Chat
getLatestMsg()
getFriendList()
checkUserStatus()
Global Chat
Chat Application
HTTP/ JSON API
WS
for Global Chat
WS
for Private Chat
ABC
DEF
XYZ
Make a simple chat (global)
Private Chat
WS
for Private Chat
ABC (mobile)
ws://?chanel=ABC&session=1
ABC (web)
XYZ
ws://?chanel=ABC&session=2
ws://?chanel=XYZ&session=1
{"ABC":[1,2],"XYZ":[1]}
DEMO PRIVATE CHAT
FRIEND-LIST & STATUS
Chat Application
HTTP/ JSON API
ABC
User sessions
{"ABC":[1,2],"XYZ":[1]}
ONLINE - OFFLINE
Chat Application
WS for Private
Chat
ABC
DEF
XYZ
PERFORMANCE !?
ONE MORE THING
• Your application feel
like a Superman, if all
your data is located on
the memory (Local
Caching is the best
solution).
• And don’t read HDD
too much.
THANK YOU!


More Related Content

What's hot

ServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBIServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBI
Gert Vanthienen
 

What's hot (20)

Spring + WebSocket integration
Spring + WebSocket integrationSpring + WebSocket integration
Spring + WebSocket integration
 
NServiceBus - introduction to a message based distributed architecture
NServiceBus - introduction to a message based distributed architectureNServiceBus - introduction to a message based distributed architecture
NServiceBus - introduction to a message based distributed architecture
 
Real-Time with Flowdock
Real-Time with FlowdockReal-Time with Flowdock
Real-Time with Flowdock
 
Building Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using WebsocketsBuilding Next Generation Real-Time Web Applications using Websockets
Building Next Generation Real-Time Web Applications using Websockets
 
ip1clientserver model
 ip1clientserver model ip1clientserver model
ip1clientserver model
 
Kopdar Zimbra-ID , How to use Zimbra SOAP API
Kopdar Zimbra-ID , How to use Zimbra SOAP APIKopdar Zimbra-ID , How to use Zimbra SOAP API
Kopdar Zimbra-ID , How to use Zimbra SOAP API
 
Realtime web application with java
Realtime web application with javaRealtime web application with java
Realtime web application with java
 
A vision for ejabberd - ejabberd SF Meetup
A vision for ejabberd - ejabberd SF MeetupA vision for ejabberd - ejabberd SF Meetup
A vision for ejabberd - ejabberd SF Meetup
 
Introduction to NServiceBus
Introduction to NServiceBusIntroduction to NServiceBus
Introduction to NServiceBus
 
Making communication across boundaries simple with Azure Service Bus
Making communication across boundaries simple with Azure Service BusMaking communication across boundaries simple with Azure Service Bus
Making communication across boundaries simple with Azure Service Bus
 
Fighting XMPP abuse and spam with ejabberd - ejabberd Workshop #1
Fighting XMPP abuse and spam with ejabberd - ejabberd Workshop #1Fighting XMPP abuse and spam with ejabberd - ejabberd Workshop #1
Fighting XMPP abuse and spam with ejabberd - ejabberd Workshop #1
 
J web socket
J web socketJ web socket
J web socket
 
WebSockets in JEE 7
WebSockets in JEE 7WebSockets in JEE 7
WebSockets in JEE 7
 
Web server
Web serverWeb server
Web server
 
Groovy example in mule
Groovy example in muleGroovy example in mule
Groovy example in mule
 
Spam Filter
Spam FilterSpam Filter
Spam Filter
 
ServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBIServiceMix 4 -- Integrating OSGi with JBI
ServiceMix 4 -- Integrating OSGi with JBI
 
HTTP/2 Changes Everything
HTTP/2 Changes EverythingHTTP/2 Changes Everything
HTTP/2 Changes Everything
 
Basic Networking in Java
Basic Networking in JavaBasic Networking in Java
Basic Networking in Java
 
web server
web serverweb server
web server
 

Viewers also liked

A project report on chat application
A project report on chat applicationA project report on chat application
A project report on chat application
Kumar Gaurav
 
Voicenger - System Requirements Specification
Voicenger - System Requirements SpecificationVoicenger - System Requirements Specification
Voicenger - System Requirements Specification
Vlad Petre
 
Tối ưu hóa việc ghi dữ liệu với Gearman
Tối ưu hóa việc ghi dữ liệu với GearmanTối ưu hóa việc ghi dữ liệu với Gearman
Tối ưu hóa việc ghi dữ liệu với Gearman
Minh Nguyen Vo Cao
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + Memcached
Ford AntiTrust
 
Building notification system in NodeJS + Redis
Building notification system in NodeJS + RedisBuilding notification system in NodeJS + Redis
Building notification system in NodeJS + Redis
Le Duc
 
Scale like a pro with Gearman
Scale like a pro with GearmanScale like a pro with Gearman
Scale like a pro with Gearman
Amal Raghav
 

Viewers also liked (20)

Императрица Екатерина II
Императрица Екатерина IIИмператрица Екатерина II
Императрица Екатерина II
 
A project report on chat application
A project report on chat applicationA project report on chat application
A project report on chat application
 
Hii - Chat Application
Hii - Chat ApplicationHii - Chat Application
Hii - Chat Application
 
SRS FOR CHAT APPLICATION
SRS FOR CHAT APPLICATIONSRS FOR CHAT APPLICATION
SRS FOR CHAT APPLICATION
 
Chat application
Chat applicationChat application
Chat application
 
WebSockets with Spring 4
WebSockets with Spring 4WebSockets with Spring 4
WebSockets with Spring 4
 
Learn node.js by building projects
Learn node.js by building projectsLearn node.js by building projects
Learn node.js by building projects
 
Windows chat application
Windows chat applicationWindows chat application
Windows chat application
 
Voicenger - System Requirements Specification
Voicenger - System Requirements SpecificationVoicenger - System Requirements Specification
Voicenger - System Requirements Specification
 
Tối ưu hóa việc ghi dữ liệu với Gearman
Tối ưu hóa việc ghi dữ liệu với GearmanTối ưu hóa việc ghi dữ liệu với Gearman
Tối ưu hóa việc ghi dữ liệu với Gearman
 
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
 
Client server chat
Client server chatClient server chat
Client server chat
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + Memcached
 
Creating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat ApplicationCreating a Java EE 7 Websocket Chat Application
Creating a Java EE 7 Websocket Chat Application
 
Gearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsGearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applications
 
Distributed RDBMS: Data Distribution Policy: Part 1 - What is a Data Distribu...
Distributed RDBMS: Data Distribution Policy: Part 1 - What is a Data Distribu...Distributed RDBMS: Data Distribution Policy: Part 1 - What is a Data Distribu...
Distributed RDBMS: Data Distribution Policy: Part 1 - What is a Data Distribu...
 
Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!
 
Building Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSocketsBuilding Real-Time Applications with Android and WebSockets
Building Real-Time Applications with Android and WebSockets
 
Building notification system in NodeJS + Redis
Building notification system in NodeJS + RedisBuilding notification system in NodeJS + Redis
Building notification system in NodeJS + Redis
 
Scale like a pro with Gearman
Scale like a pro with GearmanScale like a pro with Gearman
Scale like a pro with Gearman
 

Similar to Creating a WebSocket-Chat-Application with Jetty Embedded - Techcamp 2014

Fronteers 20131205 the realtime web
Fronteers 20131205   the realtime webFronteers 20131205   the realtime web
Fronteers 20131205 the realtime web
Bert Wijnants
 
Web Sockets are not Just for Web Browsers
Web Sockets are not Just for Web BrowsersWeb Sockets are not Just for Web Browsers
Web Sockets are not Just for Web Browsers
cjmyers
 
Dev con kolkata 2012 websockets
Dev con kolkata 2012   websocketsDev con kolkata 2012   websockets
Dev con kolkata 2012 websockets
SANKARSAN BOSE
 

Similar to Creating a WebSocket-Chat-Application with Jetty Embedded - Techcamp 2014 (20)

Behind the scenes of Real-Time Notifications
Behind the scenes of Real-Time NotificationsBehind the scenes of Real-Time Notifications
Behind the scenes of Real-Time Notifications
 
Ajax and PHP
Ajax and PHPAjax and PHP
Ajax and PHP
 
ServerSentEvents.pdf
ServerSentEvents.pdfServerSentEvents.pdf
ServerSentEvents.pdf
 
Intro to WebSockets
Intro to WebSocketsIntro to WebSockets
Intro to WebSockets
 
Fronteers 20131205 the realtime web
Fronteers 20131205   the realtime webFronteers 20131205   the realtime web
Fronteers 20131205 the realtime web
 
Real time web
Real time webReal time web
Real time web
 
ServerSentEventsV2.pdf
ServerSentEventsV2.pdfServerSentEventsV2.pdf
ServerSentEventsV2.pdf
 
Build Web Applications
Build Web ApplicationsBuild Web Applications
Build Web Applications
 
Web Sockets are not Just for Web Browsers
Web Sockets are not Just for Web BrowsersWeb Sockets are not Just for Web Browsers
Web Sockets are not Just for Web Browsers
 
Web-Socket
Web-SocketWeb-Socket
Web-Socket
 
SignalR With ASP.Net part1
SignalR With ASP.Net part1SignalR With ASP.Net part1
SignalR With ASP.Net part1
 
Java Restart with WebFX
Java Restart with WebFX Java Restart with WebFX
Java Restart with WebFX
 
Net training in bhubaneswar
Net training in bhubaneswar Net training in bhubaneswar
Net training in bhubaneswar
 
NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystem
 
Web Socket
Web SocketWeb Socket
Web Socket
 
Websocket in iOS application to create real-time applications
Websocket in iOS application to create real-time applicationsWebsocket in iOS application to create real-time applications
Websocket in iOS application to create real-time applications
 
Dev con kolkata 2012 websockets
Dev con kolkata 2012   websocketsDev con kolkata 2012   websockets
Dev con kolkata 2012 websockets
 
Project Timbit
Project TimbitProject Timbit
Project Timbit
 
Websocket vs SSE - Paris.js - 24/06/15
Websocket vs SSE - Paris.js - 24/06/15Websocket vs SSE - Paris.js - 24/06/15
Websocket vs SSE - Paris.js - 24/06/15
 
Offline of web applications
Offline of web applicationsOffline of web applications
Offline of web applications
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
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
Enterprise Knowledge
 

Recently uploaded (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 

Creating a WebSocket-Chat-Application with Jetty Embedded - Techcamp 2014