当前位置:网站首页>Polling and long polling
Polling and long polling
2022-06-25 12:28:00 【Yu Qin】
polling : To put it bluntly, the client requests the server regularly , It is the client's active request to promote data update ;
Long polling : To put it bluntly, it is also the client request server , But the server does not return immediately , Instead, the content is returned to the client only when it is updated , In terms of process , It can be understood that the server pushes content to the client ;
You can see the difference :
polling :
1: It consumes a lot of server memory and broadband resources , Because the server keeps requesting , A lot of times No new data updates , Therefore, most requests are invalid requests
2: Data is not necessarily updated in real time , It depends on the set request interval , Basically there will be delays .
Long polling :
1: Solved two major problems of polling , Real time data update ;
2: The only disadvantage is that the server consumes more memory when it is suspended ;
web In communication A long connection Long polling
be based on HTTP Long connection of , It's a long polling method “ Server push ” Technology , It makes up for HTTP The disadvantages of simple request response mode , It greatly enhances the real-time and interactivity of the program .
What is long connection 、 Long polling ?
The simple point is that the client keeps sending requests to the server and then goes to the latest data information . there ' constantly ' In fact, there is a stop . It's just that our eyes can't tell if it stops , It's just a quick stop and start connecting immediately .
Application scenarios
A long connection 、 Long polling is generally applied to webIM、ChatRoom And some website applications that need timely interaction .web Wechat QR code webQQ HI Web version ,Facebook IM etc.
Advantages and disadvantages
polling : The client sends to the server regularly Ajax request , After receiving the request, the server immediately returns the response information and closes the connection .
advantage : Back end programming is easier .
shortcoming : Most of the requests are useless , Waste bandwidth and server resources .
example : Suitable for small applications .
Long polling : The client sends to the server Ajax request , The server receives the request hold Live connection , The response information is not returned and the connection is closed until there is a new message , After the client processes the response information, it sends a new request to the server .
advantage : Not frequent requests without messages , Low cost of resources .
shortcoming : The server hold Connections consume resources , There is no guarantee for the order of data returned , Difficult to manage maintenance .
example :WebQQ、Hi Web version 、Facebook IM.
A long connection : Embed a hidden image in the page iframe, I will hide this iframe Of src Property is set to request a long connection or to adopt xhr request , The server continuously inputs data to the client based on the energy source .
advantage : Instant message arrival , No useless requests ; Management is relatively convenient .
shortcoming : Server maintenance of a long connection will increase overhead .
example :Gmail Chat
Flash Socket: Embed a usage in the page Socket Class Flash Program JavaScript By calling this Flash Provided by the program Socket Interface and server side Socket Interface to communicate ,JavaScript Control the display of the page after receiving the information sent by the server .
advantage : Real instant messaging , Not pseudo instant .
shortcoming : Client must be installed Flash plug-in unit ; Not HTTP agreement , Can't automatically cross the firewall .
example : Online interactive games .
边栏推荐
- K8s, docker compose install MySQL 8.0.18
- Execution order of MySQL query statements join, on and where
- ECSHOP quickly purchases goods, simplifies the shopping process, and improves the user experience through one-step shopping
- Image tagging to obtain the coordinates of the image in the ImageView
- ARM V7 连续加载/存储
- PD1.4转HDMI2.0转接线拆解。
- Heyangdao store management system -- share the development source code of heyangdao system
- 刷入Magisk通用方法
- 网络 | 衡量网络好坏的指标及测试方法
- JS to realize the calculation of discrete aggregation points
猜你喜欢

An article clearly explains MySQL's clustering / Federation / coverage index, back to table, and index push down

20、wpf之MVVM命令绑定

ECSHOP commodity page multi-attribute batch purchase plug-ins ECSHOP wholesale plug-ins multi-attribute order placing, multi-attribute batch purchase of commodities

Time series analysis - how to use unit root test (ADF) correctly?

What is the primordial universe

Full nanny tutorial of Market Research Competition (experience sharing)
![[论]Learning Dynamic and Hierarchical Traffic Spatiotemporal Features with Transformer](/img/58/d68112a3d019de66150e2f5102f436.png)
[论]Learning Dynamic and Hierarchical Traffic Spatiotemporal Features with Transformer

SDN系统方法 | 9. 接入网

flutter常用命令及问题

黑馬暢購商城---3.商品管理
随机推荐
The network traceroute command is used to determine the path through which IP packets access the destination address.
Development with courtesy -- share the source code of the secondary development of the app system of the imitation shopping mall
PD1.4转HDMI2.0转接线拆解。
thinkphp3.2.5 GIF. class. php for php7.4
How to use ARIMA model for prediction?
Today, I will explain to you what is DFI and its development prospects
R语言使用scale函数对神经网络的输入数据进行最小最大缩放、把数据缩放到0到1之间、并划分数据集为训练集和测试集
ECSHOP quickly purchases goods, simplifies the shopping process, and improves the user experience through one-step shopping
R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses the lrtest function of epidisplay package to perform multiple model
Is it safe to open an account and buy stocks on the Internet?
R language uses the scale function to scale the input data of neural network to the minimum and maximum, scale the data to between 0 and 1, and divide the data set into training set and test set
Controllable character image synthesis based on attribute decomposition and Gan reproduction
Renrenyue -- renrenyue system development source code sharing
The cloud native data lake has passed the evaluation and certification of the ICT Institute with its storage, computing, data management and other capabilities
Network | indicators and test methods to measure the quality of the network
Pycaret successfully resolved the problem that 'sklearn model_ selection._ Search 'import name "\u check\u param\u grid"
What is Flink? What can Flink do?
ECSHOP upload video_ ECSHOP video list, video classification, video related product guide
Architects reveal the difference between working in Alibaba, Tencent and meituan
2022 Baidu collection batch automatic push assistant