Pool for accepted sockets

Oct 14, 2011 at 7:47 AM

I have seen a little (just a little part of the server) part of your code, and I have noted you use pool (socketasynevenargs) for send and receive, but no for accepted sockets ...

I was wondering if it should be a good idea or if add some benefits in term of performance to keep a pool for accepting sockets too, in that way in high concurrent connection the client that is going to connect does not have to wait (at least the pool is all in use) for a new SAEA to be created. In this case you can keep a pool for accepting a create a new one only and only if there is no more available. (of course 10 or 20 should be enough depending on the traffic)

What do you think?



Oct 14, 2011 at 7:56 AM

The pool is used for reusing of buffer of socketasynevenargs (avoid large size/large amount buffer creation and desposing).

Only one socket can be accepted by a listening socket at the same moment, so only one socketasynevenargs is required. We needn't create so many instances of socketasynevenargs.

Oct 15, 2011 at 12:18 AM

Thanks ,,,

Yes, I know about the pool, I was just thinking on creating a pool for accepting connections (no need any buffer at all) so the acceting process will be faster because you could avoid the signaling process to accept connections and let the client get that connection and later enable again to let others be accepted ...

If for example somebody has many client request to be accepted at the same time taking from a (liittle) re-used pool should be faster than create a SAEA each time a new acceptance is needed.

Well, maybe I'm totally wrong ... it is only that I really like most of your lib.

Cheers ...


Oct 15, 2011 at 1:13 AM

If you use a pool to accept clients, synchronization cannot be avoid. Two locks are required when push item to the pool and retrieve item from pool.

Oct 15, 2011 at 3:24 AM

Yes, ... you're right ...

1.- I will try to do little test ... at this time I don't too much computers available ... just two ...

I'll try to force simultaneous connections (incrementing the request in each test) to see how can accepted SAEA pool can improve the time needed to accept and the miminum time required for rest of the clients to wait ...

Creating each time a SAEA is tme consuming ... so, the best way to know is testing ...

2.- How can you stress (simulate many client connection) a server? I was thinking in launching at least 1k per computer with a minimum of five computers. The detail here is that each client computer is stressing itself and not represent the reallity in the business world, because each client are just going to have a maximum of 7 allowed (restricted in the server by config) connections. Having more ciomputers (20 maybe) can simulate better ... of course, I'm not really sure of this, that's the reason I'm asking ... how you or usually people do ...

Once again ... thanks in advance ...



Oct 15, 2011 at 6:53 AM

I just use one client to operate 5k connections to test.