SlideShare uma empresa Scribd logo
1 de 23
Client Polling vs Server Push vs Websocket vs Long Polling
Client Pull vs Server Push
Building a real-time web application is a bit challenging one, where we need to
consider how we are going to send our data from the server to the client.
Client pull — client asking server for updates at certain regular intervals
Server push — server is proactively pushing updates to the client (reverse of
pull)
Long Polling - client makes a request to the server, but this is kept open until a
"useful" response is returned. Problem with Long polling are empty responses,
wasting bandwidth and server resources.
The difference between push & pull technology is that when a client
initiates a request from the server, it’s called a pull, and when a
server sends the information to the client within any requests, it’s
called a push.
What is server push ?
Push Technology can be referred to as pushing the information from the server
without the client’s request. It’s the opposite of the traditional client/server model,
where clients need to request a server to push the information.
It’s used to share the pre-planned information to the client like news, weather, updates
and other information that clients have not requested, but servers push the information
based on the client’s activities. Push Technology is mainly used in business to share
time-sensitive information, commodity pricing, new program promotion, or
communicate with clients and employees.
Ex of Push – Email, Push Notification on mobile app etc.
Client Polling Mechanism
The basic idea is that the client repeatedly polls (or requests) a server for data.
The client makes a request and waits for the server to respond with data. If no
data is available, an empty response is returned. Pull Technology can be referred
to as communication between client & server. It’s a traditional way of
communication between client & server. Pull Technology is mainly used to drive the
content to many applications and devices; whenever a user browses, it implies a Pull
technology where a client pulls information from the server.
Client Polling Mechanism
1.The client opens a connection and requests data from the server using
regular HTTP.
2.The requested web page sends requests to the server at regular intervals
(e.g., 0.5 seconds).
3.The server calculates the response and sends it back, just like regular HTTP
traffic.
4.The client repeats the above three steps periodically to get updates from the
server.
Client Polling Mechanism
The problem with Polling is that the client has to keep asking the server for any
new data. As a result, a lot of responses are empty, creating HTTP overhead.
Pull Mechanism Push Mechanism
When a client requests the server for the information
called pull technology.
When a server updates the information to the client
without waiting for a request called push technology.
A user using a web browser and requesting for a
web page.
An email is immediately sent from the server to the
client.
Pull Technology is used when advertisers want to
reach global audiences or build a customer base.
Push Technology is used by online advertisements,
chat, email systems, security applications and RSS
feeds.
Long Polling Mechanism
•If the server does not have any data available for the client, instead of sending
an empty response, the server holds the request and waits until some data
becomes available.
•Once the data becomes available, a full response is sent to the client. The
client then immediately re-request information from the server so that the
server will almost always have an available waiting request that it can use to
deliver data in response to an event.
Long Polling Mechanism
1.The client makes an initial request using regular HTTP and then waits for a
response.
2.The server delays its response until an update is available or a timeout has
occurred.
3.When an update is available, the server sends a full response to the client.
4.The client typically sends a new long-poll request, either immediately upon
receiving a response or after a pause to allow an acceptable latency period.
5.Each Long-Poll request has a timeout. The client has to reconnect periodically
after the connection is closed due to timeouts.
Long Polling Mechanism drawback
1.Message ordering and delivery guarantees.
1.Message ordering cannot be guaranteed if the same client opens multiple
connections to the server.
2.If the client was not able to receive the message then there will be possible
message loss.
2.Performance and scaling.
3.Device support and fall backs.
What is Websocket ?
WebSocket is a computer communication protocol which provides full-
duplex communication channels over a single TCP connection.
•It is different from HTTP but compatible with HTTP.
•Located at layer 7 in the OSI model and depends on TCP at layer 4.
•Works over port 80 and 443 ( in case of TLS encrypted) and supports HTTP
proxies and intermediaries.
•To achieve compatibility, the WebSocket handshake uses Upgrade header to
update the protocol to the WebSocket protocol.
Websocket
WebSocket workflow
1.A client initiates a WebSocket handshake process by sending a request which
also contains Upgrade header to switch to WebSocket protocol along with
other information.
2.The server receives WebSocket handshake request and process it.
1.If the server can establish the connection and agrees with client terms then
sends a response to the client, acknowledging the WebSocket handshake
request with other information.
2.If the server can not establish the connection then it sends response
acknowledging it cannot establish WebSocket connection.
3.Once the client receives a successful WebSocket connection handshake
request, WebSocket connection will be opened. Now, client and servers can
start sending data in both directions allowing real-time communication.
4.The connection will be closed once the server or the client decides to close
the connection.
WebSocket Pros and Cons
Pros
•WebSockets keeps a unique connection open while eliminating latency problems
that arise with Long Polling.
•WebSockets generally do not use XMLHttpRequest, and as such, headers are not
sent every-time we need to get more information from the server. This, in turn,
reduces the expensive data loads being sent to the server.
Cons
•WebSockets don’t automatically recover when connections are terminated — this is
something you need to implement yourself, and is part of the reason why there are
many client-side libraries in existence.
•Browsers older than 2011 aren’t able to support WebSocket connections — but this
is increasingly less relevant.
WebSocket vs Long polling
Long polling is much more resource intensive on servers whereas WebSockets
have an extremely lightweight footprint on servers. Long polling also requires
many hops between servers and devices. And these gateways often have
different ideas of how long a typical connection is allowed to stay open. If it
stays open too long something may kill it, maybe even when it was doing
something important.
Why you should build with WebSockets:
•Full-duplex asynchronous messaging. In other words, both the client and the
server can stream messages to each other independently.
•WebSockets pass through most firewalls without any reconfiguration.
•Good security model (origin-based security model).
Server Push
Server-Sent Events are a one-way communication channel where events flow
from server to client only. Server-Sent Events allows browser clients to
receive a stream of events from a server over an HTTP connection without
polling.
A client subscribes to a “stream” from a server and the server will send
messages (“event-stream”) to the client until the server or the client closes the
stream. It is up to the server to decide when and what to send the client, for
instance as soon as data changes.
Server
Push
Server Push workflow
1.Browser client creates a connection using an EventSource API with a server
endpoint which is expected to return a stream of events over time. This
essentially makes an HTTP request at given URL.
2.The server receives a regular HTTP request from the client and opens the
connection and keeps it open. The server can now send the event data as long
as it wants or it can close the connection if there are no data.
3.The client receives each event from the server and process it. If it receives a
close signal from the server it can close the connection. The client can also
initiate the connection close request.
WebSocket vs Server Push
WebSockets are undoubtedly more complex and demanding than SSEs, and
require a bit of developer input up front. For this investment, you gain a full-
duplex TCP connection that is useful for a wider range of application scenarios.
For example WebSockets tend to be preferable for use cases such as multi-
player games or location-based apps. Where Serve Push can technically be
used to achieve these, this might cause the domain to get multiplexed.
WebSocket vs Server Push
WebSockets provide bidirectional client-server communication between clients and
servers. This kind of functionality is vastly applied and appreciated in technologies
technologies like real-time polling applications, chat applications, media players and
players and the like.
Server Push do not provide bidirectional communication. However, there are so
many applications where there’s no need to send data from the client. Cases like this
like this are updating statuses, push notifications, newsletters and news feeds. In
In scenarios like this, SSEs are most appreciated.
THANK YOU
Like the Video and Subscribe the Channel

Mais conteúdo relacionado

Mais procurados

Open stack networking vlan, gre
Open stack networking   vlan, greOpen stack networking   vlan, gre
Open stack networking vlan, gre
Sim Janghoon
 
Creating_scheduled_reports_with_Zabbix.pdf
Creating_scheduled_reports_with_Zabbix.pdfCreating_scheduled_reports_with_Zabbix.pdf
Creating_scheduled_reports_with_Zabbix.pdf
ITDispendik
 

Mais procurados (20)

Multi processing
Multi processingMulti processing
Multi processing
 
Mikrotik metarouter
Mikrotik metarouterMikrotik metarouter
Mikrotik metarouter
 
Syncing the cloud - from T1 to TAP
 Syncing the cloud - from T1 to TAP Syncing the cloud - from T1 to TAP
Syncing the cloud - from T1 to TAP
 
Distance Vector Multicast Routing Protocol (DVMRP) : Presentation
Distance Vector Multicast Routing Protocol (DVMRP) : PresentationDistance Vector Multicast Routing Protocol (DVMRP) : Presentation
Distance Vector Multicast Routing Protocol (DVMRP) : Presentation
 
Processor allocation in Distributed Systems
Processor allocation in Distributed SystemsProcessor allocation in Distributed Systems
Processor allocation in Distributed Systems
 
Citrix adc technical overview
Citrix adc   technical overviewCitrix adc   technical overview
Citrix adc technical overview
 
Open stack networking vlan, gre
Open stack networking   vlan, greOpen stack networking   vlan, gre
Open stack networking vlan, gre
 
Room 3 - 4 - Lê Quang Hiếu - How to be a cool dad: Leverage DIY Home Automati...
Room 3 - 4 - Lê Quang Hiếu - How to be a cool dad: Leverage DIY Home Automati...Room 3 - 4 - Lê Quang Hiếu - How to be a cool dad: Leverage DIY Home Automati...
Room 3 - 4 - Lê Quang Hiếu - How to be a cool dad: Leverage DIY Home Automati...
 
Rtp
RtpRtp
Rtp
 
Storage tiering and erasure coding in Ceph (SCaLE13x)
Storage tiering and erasure coding in Ceph (SCaLE13x)Storage tiering and erasure coding in Ceph (SCaLE13x)
Storage tiering and erasure coding in Ceph (SCaLE13x)
 
AVB intro
AVB introAVB intro
AVB intro
 
2019.06.27 Intro to Ceph
2019.06.27 Intro to Ceph2019.06.27 Intro to Ceph
2019.06.27 Intro to Ceph
 
Precision Time Protocol
Precision Time ProtocolPrecision Time Protocol
Precision Time Protocol
 
Geo data analytics
Geo data analyticsGeo data analytics
Geo data analytics
 
Prometheus in openstack-helm
Prometheus in openstack-helmPrometheus in openstack-helm
Prometheus in openstack-helm
 
Server Virtualization using Hyper-V
Server Virtualization using Hyper-VServer Virtualization using Hyper-V
Server Virtualization using Hyper-V
 
Grafana Mimir and VictoriaMetrics_ Performance Tests.pptx
Grafana Mimir and VictoriaMetrics_ Performance Tests.pptxGrafana Mimir and VictoriaMetrics_ Performance Tests.pptx
Grafana Mimir and VictoriaMetrics_ Performance Tests.pptx
 
OpenDaylight Integration with OpenStack Neutron: A Tutorial
OpenDaylight Integration with OpenStack Neutron: A TutorialOpenDaylight Integration with OpenStack Neutron: A Tutorial
OpenDaylight Integration with OpenStack Neutron: A Tutorial
 
Creating_scheduled_reports_with_Zabbix.pdf
Creating_scheduled_reports_with_Zabbix.pdfCreating_scheduled_reports_with_Zabbix.pdf
Creating_scheduled_reports_with_Zabbix.pdf
 
RTI DDS Intro with DDS Secure
RTI DDS Intro with DDS SecureRTI DDS Intro with DDS Secure
RTI DDS Intro with DDS Secure
 

Semelhante a Difference between Client Polling vs Server Push vs Websocket vs Long Polling

Web Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdfWeb Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdf
Raghunathan52
 
Web Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdfWeb Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdf
Raghunathan52
 
Building Realtime Web Applications With ASP.NET SignalR
Building Realtime Web Applications With ASP.NET SignalRBuilding Realtime Web Applications With ASP.NET SignalR
Building Realtime Web Applications With ASP.NET SignalR
Shravan Kumar Kasagoni
 

Semelhante a Difference between Client Polling vs Server Push vs Websocket vs Long Polling (20)

EAI design patterns/best practices
EAI design patterns/best practicesEAI design patterns/best practices
EAI design patterns/best practices
 
What is a WebSocket? Real-Time Communication in Applications
What is a WebSocket? Real-Time Communication in ApplicationsWhat is a WebSocket? Real-Time Communication in Applications
What is a WebSocket? Real-Time Communication in Applications
 
ClientServer Websocket.pptx
ClientServer Websocket.pptxClientServer Websocket.pptx
ClientServer Websocket.pptx
 
05 20254 financial stock application
05 20254 financial stock application05 20254 financial stock application
05 20254 financial stock application
 
IRJET- An Overview of Web Sockets: The Future of Real-Time Communication
IRJET- An Overview of Web Sockets: The Future of Real-Time CommunicationIRJET- An Overview of Web Sockets: The Future of Real-Time Communication
IRJET- An Overview of Web Sockets: The Future of Real-Time Communication
 
Real-time Communications with SignalR
Real-time Communications with SignalRReal-time Communications with SignalR
Real-time Communications with SignalR
 
Web Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdfWeb Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdf
 
Web Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdfWeb Technologies Notes - TutorialsDuniya.pdf
Web Technologies Notes - TutorialsDuniya.pdf
 
Http_Protocol.pptx
Http_Protocol.pptxHttp_Protocol.pptx
Http_Protocol.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
 
Web Socket
Web SocketWeb Socket
Web Socket
 
Building Realtime Web Applications With ASP.NET SignalR
Building Realtime Web Applications With ASP.NET SignalRBuilding Realtime Web Applications With ASP.NET SignalR
Building Realtime Web Applications With ASP.NET SignalR
 
Www and http
Www and httpWww and http
Www and http
 
Web server
Web serverWeb server
Web server
 
0130225347
01302253470130225347
0130225347
 
Java Networking
Java NetworkingJava Networking
Java Networking
 
Http smuggling 1 200523064027
Http smuggling 1 200523064027Http smuggling 1 200523064027
Http smuggling 1 200523064027
 
HTTP Request Smuggling
HTTP Request SmugglingHTTP Request Smuggling
HTTP Request Smuggling
 
1-1.pdf
1-1.pdf1-1.pdf
1-1.pdf
 
Decoding real time web communication
Decoding real time web communicationDecoding real time web communication
Decoding real time web communication
 

Mais de jeetendra mandal

Mais de jeetendra mandal (20)

what is OSI model
what is OSI modelwhat is OSI model
what is OSI model
 
What is AWS Cloud Watch
What is AWS Cloud WatchWhat is AWS Cloud Watch
What is AWS Cloud Watch
 
What is AWS Fargate
What is AWS FargateWhat is AWS Fargate
What is AWS Fargate
 
Eventual consistency vs Strong consistency what is the difference
Eventual consistency vs Strong consistency what is the differenceEventual consistency vs Strong consistency what is the difference
Eventual consistency vs Strong consistency what is the difference
 
Batch Processing vs Stream Processing Difference
Batch Processing vs Stream Processing DifferenceBatch Processing vs Stream Processing Difference
Batch Processing vs Stream Processing Difference
 
Difference between Database vs Data Warehouse vs Data Lake
Difference between Database vs Data Warehouse vs Data LakeDifference between Database vs Data Warehouse vs Data Lake
Difference between Database vs Data Warehouse vs Data Lake
 
Difference between TLS 1.2 vs TLS 1.3 and tutorial of TLS2 and TLS2 version c...
Difference between TLS 1.2 vs TLS 1.3 and tutorial of TLS2 and TLS2 version c...Difference between TLS 1.2 vs TLS 1.3 and tutorial of TLS2 and TLS2 version c...
Difference between TLS 1.2 vs TLS 1.3 and tutorial of TLS2 and TLS2 version c...
 
Difference Program vs Process vs Thread
Difference Program vs Process vs ThreadDifference Program vs Process vs Thread
Difference Program vs Process vs Thread
 
Carrier Advice for a JAVA Developer How to Become a Java Programmer
Carrier Advice for a JAVA Developer How to Become a Java ProgrammerCarrier Advice for a JAVA Developer How to Become a Java Programmer
Carrier Advice for a JAVA Developer How to Become a Java Programmer
 
How to become a Software Tester Carrier Path for Software Quality Tester
How to become a Software Tester Carrier Path for Software Quality TesterHow to become a Software Tester Carrier Path for Software Quality Tester
How to become a Software Tester Carrier Path for Software Quality Tester
 
How to become a Software Engineer Carrier Path for Software Developer
How to become a Software Engineer Carrier Path for Software DeveloperHow to become a Software Engineer Carrier Path for Software Developer
How to become a Software Engineer Carrier Path for Software Developer
 
Events vs Notifications
Events vs NotificationsEvents vs Notifications
Events vs Notifications
 
Microservice Architecture Software Architecture Microservice Design Pattern
Microservice Architecture Software Architecture Microservice Design PatternMicroservice Architecture Software Architecture Microservice Design Pattern
Microservice Architecture Software Architecture Microservice Design Pattern
 
Event Driven Software Architecture Pattern
Event Driven Software Architecture PatternEvent Driven Software Architecture Pattern
Event Driven Software Architecture Pattern
 
Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...
Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...
Top 5 Software Architecture Pattern Event Driven SOA Microservice Serverless ...
 
Observability vs APM vs Monitoring Comparison
Observability vs APM vs  Monitoring ComparisonObservability vs APM vs  Monitoring Comparison
Observability vs APM vs Monitoring Comparison
 
Disaster Recovery vs Data Backup what is the difference
Disaster Recovery vs Data Backup what is the differenceDisaster Recovery vs Data Backup what is the difference
Disaster Recovery vs Data Backup what is the difference
 
What is Spinnaker? Spinnaker tutorial
What is Spinnaker? Spinnaker tutorialWhat is Spinnaker? Spinnaker tutorial
What is Spinnaker? Spinnaker tutorial
 
Difference between Github vs Gitlab vs Bitbucket
Difference between Github vs Gitlab vs BitbucketDifference between Github vs Gitlab vs Bitbucket
Difference between Github vs Gitlab vs Bitbucket
 
Difference between Git and Github
Difference between Git and GithubDifference between Git and Github
Difference between Git and Github
 

Último

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 

Último (20)

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 

Difference between Client Polling vs Server Push vs Websocket vs Long Polling

  • 1. Client Polling vs Server Push vs Websocket vs Long Polling
  • 2. Client Pull vs Server Push Building a real-time web application is a bit challenging one, where we need to consider how we are going to send our data from the server to the client. Client pull — client asking server for updates at certain regular intervals Server push — server is proactively pushing updates to the client (reverse of pull) Long Polling - client makes a request to the server, but this is kept open until a "useful" response is returned. Problem with Long polling are empty responses, wasting bandwidth and server resources.
  • 3. The difference between push & pull technology is that when a client initiates a request from the server, it’s called a pull, and when a server sends the information to the client within any requests, it’s called a push.
  • 4. What is server push ? Push Technology can be referred to as pushing the information from the server without the client’s request. It’s the opposite of the traditional client/server model, where clients need to request a server to push the information. It’s used to share the pre-planned information to the client like news, weather, updates and other information that clients have not requested, but servers push the information based on the client’s activities. Push Technology is mainly used in business to share time-sensitive information, commodity pricing, new program promotion, or communicate with clients and employees. Ex of Push – Email, Push Notification on mobile app etc.
  • 5.
  • 6. Client Polling Mechanism The basic idea is that the client repeatedly polls (or requests) a server for data. The client makes a request and waits for the server to respond with data. If no data is available, an empty response is returned. Pull Technology can be referred to as communication between client & server. It’s a traditional way of communication between client & server. Pull Technology is mainly used to drive the content to many applications and devices; whenever a user browses, it implies a Pull technology where a client pulls information from the server.
  • 7. Client Polling Mechanism 1.The client opens a connection and requests data from the server using regular HTTP. 2.The requested web page sends requests to the server at regular intervals (e.g., 0.5 seconds). 3.The server calculates the response and sends it back, just like regular HTTP traffic. 4.The client repeats the above three steps periodically to get updates from the server.
  • 8. Client Polling Mechanism The problem with Polling is that the client has to keep asking the server for any new data. As a result, a lot of responses are empty, creating HTTP overhead.
  • 9. Pull Mechanism Push Mechanism When a client requests the server for the information called pull technology. When a server updates the information to the client without waiting for a request called push technology. A user using a web browser and requesting for a web page. An email is immediately sent from the server to the client. Pull Technology is used when advertisers want to reach global audiences or build a customer base. Push Technology is used by online advertisements, chat, email systems, security applications and RSS feeds.
  • 10. Long Polling Mechanism •If the server does not have any data available for the client, instead of sending an empty response, the server holds the request and waits until some data becomes available. •Once the data becomes available, a full response is sent to the client. The client then immediately re-request information from the server so that the server will almost always have an available waiting request that it can use to deliver data in response to an event.
  • 11. Long Polling Mechanism 1.The client makes an initial request using regular HTTP and then waits for a response. 2.The server delays its response until an update is available or a timeout has occurred. 3.When an update is available, the server sends a full response to the client. 4.The client typically sends a new long-poll request, either immediately upon receiving a response or after a pause to allow an acceptable latency period. 5.Each Long-Poll request has a timeout. The client has to reconnect periodically after the connection is closed due to timeouts.
  • 12. Long Polling Mechanism drawback 1.Message ordering and delivery guarantees. 1.Message ordering cannot be guaranteed if the same client opens multiple connections to the server. 2.If the client was not able to receive the message then there will be possible message loss. 2.Performance and scaling. 3.Device support and fall backs.
  • 13. What is Websocket ? WebSocket is a computer communication protocol which provides full- duplex communication channels over a single TCP connection. •It is different from HTTP but compatible with HTTP. •Located at layer 7 in the OSI model and depends on TCP at layer 4. •Works over port 80 and 443 ( in case of TLS encrypted) and supports HTTP proxies and intermediaries. •To achieve compatibility, the WebSocket handshake uses Upgrade header to update the protocol to the WebSocket protocol.
  • 15. WebSocket workflow 1.A client initiates a WebSocket handshake process by sending a request which also contains Upgrade header to switch to WebSocket protocol along with other information. 2.The server receives WebSocket handshake request and process it. 1.If the server can establish the connection and agrees with client terms then sends a response to the client, acknowledging the WebSocket handshake request with other information. 2.If the server can not establish the connection then it sends response acknowledging it cannot establish WebSocket connection. 3.Once the client receives a successful WebSocket connection handshake request, WebSocket connection will be opened. Now, client and servers can start sending data in both directions allowing real-time communication. 4.The connection will be closed once the server or the client decides to close the connection.
  • 16. WebSocket Pros and Cons Pros •WebSockets keeps a unique connection open while eliminating latency problems that arise with Long Polling. •WebSockets generally do not use XMLHttpRequest, and as such, headers are not sent every-time we need to get more information from the server. This, in turn, reduces the expensive data loads being sent to the server. Cons •WebSockets don’t automatically recover when connections are terminated — this is something you need to implement yourself, and is part of the reason why there are many client-side libraries in existence. •Browsers older than 2011 aren’t able to support WebSocket connections — but this is increasingly less relevant.
  • 17. WebSocket vs Long polling Long polling is much more resource intensive on servers whereas WebSockets have an extremely lightweight footprint on servers. Long polling also requires many hops between servers and devices. And these gateways often have different ideas of how long a typical connection is allowed to stay open. If it stays open too long something may kill it, maybe even when it was doing something important. Why you should build with WebSockets: •Full-duplex asynchronous messaging. In other words, both the client and the server can stream messages to each other independently. •WebSockets pass through most firewalls without any reconfiguration. •Good security model (origin-based security model).
  • 18. Server Push Server-Sent Events are a one-way communication channel where events flow from server to client only. Server-Sent Events allows browser clients to receive a stream of events from a server over an HTTP connection without polling. A client subscribes to a “stream” from a server and the server will send messages (“event-stream”) to the client until the server or the client closes the stream. It is up to the server to decide when and what to send the client, for instance as soon as data changes.
  • 20. Server Push workflow 1.Browser client creates a connection using an EventSource API with a server endpoint which is expected to return a stream of events over time. This essentially makes an HTTP request at given URL. 2.The server receives a regular HTTP request from the client and opens the connection and keeps it open. The server can now send the event data as long as it wants or it can close the connection if there are no data. 3.The client receives each event from the server and process it. If it receives a close signal from the server it can close the connection. The client can also initiate the connection close request.
  • 21. WebSocket vs Server Push WebSockets are undoubtedly more complex and demanding than SSEs, and require a bit of developer input up front. For this investment, you gain a full- duplex TCP connection that is useful for a wider range of application scenarios. For example WebSockets tend to be preferable for use cases such as multi- player games or location-based apps. Where Serve Push can technically be used to achieve these, this might cause the domain to get multiplexed.
  • 22. WebSocket vs Server Push WebSockets provide bidirectional client-server communication between clients and servers. This kind of functionality is vastly applied and appreciated in technologies technologies like real-time polling applications, chat applications, media players and players and the like. Server Push do not provide bidirectional communication. However, there are so many applications where there’s no need to send data from the client. Cases like this like this are updating statuses, push notifications, newsletters and news feeds. In In scenarios like this, SSEs are most appreciated.
  • 23. THANK YOU Like the Video and Subscribe the Channel