简体   繁体   中英

websocket pooling in asp.net?

i have read about pooling websockets to improve performance here but i honestly have no idea what he really means and how to actually implement it.

the Original qoute from author:

WebSocket connections are initiated as traditional HTTP connections. The client then usually requests an “upgrade” to a WebSocket session, this upgradae process is relatively expensive. If you are interested in performance you may want to pool a set of connection that are already upgraded and use connections from the pool.

any description about concept or implementation is much appreciated.

I think it is talking about when you are a CLIENT and you have multiple connections to the same SERVER.

Why would you have multiple connections to the same SERVER? Well, if you are using WebSockets to process large amounts of data, or doing streaming (audio, video, etc..), it may make sense. In the WebSocket protocol you can interleave protocol frames with data frames, but you cannot interleave data frames from two different messages, which means that if you have to pass 2Gb of data through the connection, you cannot process anything else through that connection until that large message is sent. Having multiple connections would allow you to process two things at the same time by sharing the bandwidth.

Connection pooling works by having for example a stack (or a queue) of connections that can be used as a pool. When you need to use one, you remove it from the pool, and when you are done, you push it to the pool again, making it available for other consumers to use. Those connections are being kept "warm" in the pool, so consumers just grab one and use it, without having to wait for that connection to be initialized.

More info: Connection pool

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM