Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[js] 第363天 使用ajax轮询接口有什么优缺点? #2234

Open
haizhilin2013 opened this issue Apr 12, 2020 · 3 comments
Open

[js] 第363天 使用ajax轮询接口有什么优缺点? #2234

haizhilin2013 opened this issue Apr 12, 2020 · 3 comments
Labels
js JavaScript

Comments

@haizhilin2013
Copy link
Collaborator

第363天 使用ajax轮询接口有什么优缺点?

#37

我也要出题

@haizhilin2013 haizhilin2013 added the js JavaScript label Apr 12, 2020
@makejun168
Copy link

首先,所谓轮询接口的原理是 利用 setTimeout 定时请求API接口

优点:
1,可以简单不用二次 开发websocket 实现所需功能 几乎没有学习成本
2,使用简单
缺点:
1,性能相对 socket 来说 相对差,利用 setTimeout 定时请求接口 占用内存性能 定时任务,又可能请求超时导致内存溢出
2,请求返回数据不稳定,请求失败断连 重连机制

@bozaigao
Copy link

bozaigao commented Oct 9, 2020

@makejun168 应该是setInterval轮询吧

@bozaigao
Copy link

bozaigao commented Oct 9, 2020

轮询的优点是:简单;
缺点是:响应不及时、网络流量消耗大。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js JavaScript
Projects
None yet
Development

No branches or pull requests

3 participants