Home > Net > C # how to control the user requests?
C # how to control the user requests?
Time:11-04
Ask a question: There is a demand to save users to upload video files, (client is write a Windows service, regular query to upload), now need to limit the number of users transfer files at the same time 5 to 10 what of, don't care about the efficiency, complete line, the what? Colleagues say thread pool, but recently the thread pool, a need to create a large number of threads used when, this don't feel for me? Have a big kind under the light?
CodePudding user response:
SemaphoreSlim this good
As for the thread pool, in fact, too, but not the thread pool, but any pool, anything can pool, two words not said you have to take the thread pool,
CodePudding user response:
Actually this belongs to the "current limit" operation, the current limiting means a lot, pooling is just one of SemaphoreSlim is pooling control to realize the basic
Because I don't know the specific environment, we can search relevant product keyword in nuget RateLimiter
https://www.nuget.org/packages? Q=RateLimiter
If it is a webapi, nuget has achieved good call WebApiThrottle
CodePudding user response:
The client is a Windows service?? That is video file transfer between the server side, use socket travels? From already have to do is to control the number of connections, more than just refused to Accept, if the client disconnected, connect number minus 1. After the transfer, can also be active on the server disconnected, connect number minus 1.