问题描述
我开始开发一个软件,使用html + js编码的应用程序我需要使用nginx for routiong从服务器(java代码)发送此应用程序通知,并托管在AWS中。
我调查了这个实时通知主题,我在网络套接字与长轮询之间感到困惑
I start developing a software, app coded using html + js I need to send this app notification from the server (java code) the app using nginx for routiong and is hosted in AWS.I investigated this subject of real time notification and I get confused between web sockets to long pollingIn what situations would AJAX long/short polling be preferred over HTML5 WebSockets?
在一些文章中,我读到长轮询是一个旧的不像websocket更新更好()
我开始检查gmail的元素facebook whatsapp web页面。
我看到使用长轮询的Gmail + facebook与使用Websocket的whatsapp不同。
为什么这些公司仍然选择使用长轮询?
In some articles I read that long polling is an old unlike websocket which is newer and better (In what situations would AJAX long/short polling be preferred over HTML5 WebSockets? )I start inspect element of gmail facebook whatsapp web pages.I saw that Gmail+ facebook using long polling Unlike whatsapp which using Websocket.So why these companies still choose to use long polling?https://www.quora.com/Does-Facebook-use-WebSockets-for-any-of-their-applications-Are-they-really-useful-at-that-scale-especially-since-they-impose-a-stateful-architecture
推荐答案
一些公司仍在使用长轮询的几个原因:
A couple of reasons why some companies are still using long-polling:
- WebSocket支持仍然不是100%,即使没有支持的传统浏览器正在慢慢消失。因此,如果您是Google这样的公司,产品必须在几乎所有浏览器上运行,那么您仍然需要非WebSocket后备解决方案。
- 如果您已经有了可行的解决方案那么转移到WebSocket的成本可能会超过它带来的节省。
这篇关于Longpolling与Websockets的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!