What is the proper lag for an asynchronous server socket?

If you are working with an asynchronous server socket in C #, what is the proper reserve for connecting to the socket? For instance:

server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPEndPoint iep = new IPEndPoint(IPAddress.Any, port); server.Bind(iep); server.Listen(10); 
+4
source share
1 answer

In most applications, the listener itself is probably not a bottleneck. Most often, you need to answer these TCP requests by doing some work, and the number of workers that your application can efficiently use at a time will be less than the number of connections that theoretically can support.

This probably explains the "rule of thumb" by Alexei Martelli in the comments:

I am always inclined to use 5 , but I have no acutely argued explanation of why.

On a quad-core server, this makes sense if clients start tasks with heavy processor utilization; 4 connections for 4 workers / threads / cores and another to support heavy load maintenance.

If your work does not require intensive use of resources, then the above limit / explanation does not matter to you, you can manage 10 or 50 connections, or you may need to use some resource exclusive to the machine and allow only one, I basically agree with Hans in the fact that this is not a hard and fast "right answer", you need to see what makes your application, make an estimate regarding how many connections you think he can really handle, and set it to mak imalnoy effectiveness by testing.

+3
source

Source: https://habr.com/ru/post/1309177/


All Articles