Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF async server side processing

I need to create a WCF service that accept client request and internally connect to a remote machine to do the job. The remote machine has a very good processing capacity but not a good processing speed. This means that can process for example 1000 transactions per second but each transaction can take 1 second, so the only way is to have 1.000 concurrent transactions running in the same second.

The remote machine handle very well this situation, but I am worried about WCF, if each transaction is internally (I dont care the client side model (sync or async)) waiting and blocking a thread inside the server for 1 or 2 seconds this could represent a 1.000 working threads live and that could be very dangerous, or maybe WCF use the thread pool and just put others request in a waiting state and that is bad too.

So, my question is about the possibility of processing the request asynchronously in the server side. So the transaction flow must be like this:

  1. Cliente initialize a request (in his side is a synchronous request)
  2. Server recive the request and put this request in a Transaction Queue and release the thread
  3. When the task finish, the server complete the request sending HTTP 200 and result to the client.

Thanks!

like image 758
Anibal David Acosta Avatar asked Nov 14 '22 14:11

Anibal David Acosta


1 Answers

You can use the WCF async pattern to achieve this. When you mark your operationContract with the async attribute, WCF uses the IO CompletionPort threads to process the request.

so it works the following way. Your request is handleded by a thread in IIS and once it reaches WCF it goes to sleep and then the IO CompletionPort thread takes the request process it and then sends back the response to the IIS thread that returns the response to the client.

IO CompletionPort threads are much faster and also doesnt slow down your server in terms of performance or resources.

Look at the following link for more information.

like image 171
Rajesh Avatar answered Nov 23 '22 23:11

Rajesh