MSDN documentation doesn’t seem to have good coverage on ASP.net 4.5 support of HTML5 WebSockets protocol!
This is what I’m looking for:
- How many live connections can a server/application/cpu support?
- Is there any maximum number of incoming connections that could be set/get?
- What is the optimum number of sockets per application regardless of data transfer over the socket?
Update:
Requests from flash RTMP sockets (an alternative to websocket) could be well configured on Adobe Media Server application server. Isn’t any sort of configurations for number of requests, ideal time, size of chunks, … for ASP.net inside application or IIS 8 configuration?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
To whomever may be interested:
- Over 100k WebSocket connections can be made to a single server
running ASP.NET 4.5 -
WebSocket connections are initiated by a HTTP
handshake, hence some of the IIS throttles that apply to HTTP requests
will also apply to WebSockets.
appConcurrentRequestLimitin the IIS Configuration can be used to set the maximum concurrent requests per application:<serverRuntime appConcurrentRequestLimit="250000" />
-
Maximum concurrent connections to an ASP.net 4 Web Application can be set with ApplicationPool’s maxConcurrentRequestsPerCPU property:
<system.web> <applicationPool maxConcurrentRequestsPerCPU="20000" /> </system.web> -
When the total amount of connections exceed the
maxConcurrentRequestsPerCPUsetting, ASP.NET will start throttling requests using a queue. To control the size of the queue, you can
tweak the machine.config requestQueueLimit:<processModel autoConfig="false" requestQueueLimit="250000" />
-
The following performance counters should be considered while
conducting concurrency testing and adjusting the optimum settings
detailed above:- NET CLR Memory #bytes in all Heaps
- ASP.NETRequests Current – Queued – Rejected
- Processor InformationProcessor Time
- TCP/IP Connections Established
- Web ServiceCurrent Connections – Maximum Connections
- .NET CLR LocksAndThreads # of current logical Threads – # of current physical Threads
Method 2
EDIT: This answer is related to .Net 4.0 or older versions, where WebSockets have to be implemented by your own (.Net 4.5 + IIS provides you with solution). So it only relates to your own implementation of WebSockets on top of TCP Layer.
Amount of sockets that can be handled by .Net is based on system and the way you serve the sockets. Read this: http://msdn.microsoft.com/en-us/library/windows/desktop/ms739169%28v=vs.85%29.aspx
WebSockets implementation is using Asynchronous way of serving Receiving and Sending of data. That makes them very scalable and does not require a lot of memory per connection.
So amount of connected sockets is based on complexity of your application logic to each connection and hardware. In most cases you will face performance issues with processing application logic, then facing performance issues that will be based just on connected sockets.
If you are using own implementation that is based on raw TCP Sockets then this information will apply:
On single networking device you can Bind a bit less than 65k sockets. This is listening sockets that accept connections. In usual server implementations you would almost never use more then a few or maybe few 10ths of sockets for accepting connections.
Client sockets can be as many as your implementation and memory can handle.
There is many ways of serving sockets, that allows you to handle more sockets.
Few highlights:
- Blocking way of serving sockets will delay of serving each socket. As well non-blocking read of client sockets will use your cpu for just checking if there is any data available. With huge amount of sockets it can be very costy.
- Thread per client socket will use huge amount of memory (more then 1mb per thread), that will allow you small amount of sockets per physical system.
- One of the best (imho) options is using Asynchronous socket. That allows you to have thousands of sockets, and with good implementation more that tens or even hundreds thousands sockets on single server system.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0