腹板的缺点 [英] disadvantages of websockets

查看:113
本文介绍了腹板的缺点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道使用websockets有什么样的限制。

I would like to know what kind of limitations there are in using websockets.

Websockets就是这么强大。我无法想象它没有缺点。

Websockets is just so.. powerful. I can't imagine that it is without disadvantages.

说,可以同时连接到服务器的用户数量是多少(如果我正在创建一个游戏和用户将通过WebSockets连接到游戏,什么会限制一次能够连接的用户数量?)

Say, what is the number of users that can simultaneously connect to a server (if I'm creating a game and users will connect to the game through WebSockets, what will limit the number of users able to connect at any one time?)

对于每个额外的连接,也是如此连接的质量(速度和类似的东西)会减少吗?

Also is it true that with each additional connection, the quality of the connections (speed and stuff like that) will decrease?

推荐答案

优点和缺点当然取决于具体的用例,但我会试着指出WebSocket和HTTP之间的一些区别。

The advantages and disadvantages will of course depend on the specific use case, but I'll try to point out some differences between WebSocket and HTTP.

WebSocket比HTTP更复杂。您可以与telnet客户端建立HTTP连接,但您可能无法对WS执行相同操作。即使您忽略了握手要求(包括使用SHA1散列函数),您也无法正确屏蔽和构建要发送的数据,服务器将关闭连接。

WebSocket is more complex than HTTP. You can establish an HTTP connection with a telnet client, but you probably cannot do the same with WS. Even if you ignored the handshake requirements (which include the use of the SHA1 hash function), you would then be unable to properly mask and frame the data to be sent, and the server would close the connection.

正如Uwe所说,WebSocket连接旨在比HTTP连接更持久。如果您只想每30分钟收到一次更新,则需要使用HTTP。如果你想每秒接收更新,WebSocket可能是更好的选择,因为建立HTTP连接需要花费很多时间。

As Uwe said, WebSocket connections are intended to be more persistent than HTTP connections. If you only want to receive an update every 30 minutes, you will want to go with HTTP. If you want to receive updates every second, a WebSocket might be a better option, because establishing an HTTP connection takes a lot of time.

要建立HTTP连接,你需要首先必须建立TCP连接(SYN,SYN / ACK,ACK),然后发送一个带有相当大的头的GET请求,然后最终收到服务器的响应(以及另一个大头)。

To establish an HTTP connection, you first have to establish a TCP connection (SYN, SYN/ACK, ACK), then send a GET request with a pretty big header, then finally receive the server's response (along with another big header).

使用开放的WebSocket,您只需收到响应(无需请求),并且它带有一个小得多的标头:从两个字节开始用于小帧,最多10个字节用于可笑的大帧(在千兆字节中)范围)。

With an open WebSocket you simply receive the response (no request needed), and it comes with a much smaller header: from two bytes for small frames, up to 10 bytes for ridiculously large frames (in the gigabyte range).

你需要权衡两个成本(保持连接打开与建立新连接)来决定两个协议。

You need to weigh the two costs (keeping a connection open vs establishing a new connection) to decide between the two protocols.

注意:这个答案是基于当前的协议草案(draft-ietf-hybi-thewebsocketprotocol-09)。 WebSocket正在快速发展,许多实现仍然基于较旧的草案,并且一些细节可能在最终确定之前发生变化。

Note: this answer is based on the current draft of the protocol (draft-ietf-hybi-thewebsocketprotocol-09). WebSocket is evolving rapidly, many implementations are still based on older drafts, and some details may change before it is finalized.

这篇关于腹板的缺点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆