Huge Performance Difference when Same Task is Executed in Self-Hosted WCF and in MVC
I have created a Custom ThreadPool which Accepts Jobs from Client, Processes it and Returns the Results. Currently this is running in MVC Application. Where User Uploads the Job to be done using a form, Server will process it and return the Report. The Processing involves Sending SOAP Requests to Multiple External Services and Accumulating the Response.
开发者_如何学运维Recently I created a Windows Based application which can automate the Uploading Tasks and also will handle Callbacks for Current Status of the Job. Thus I implemented a WCF Service with netTCPBinding & Callback Contract & Hosted it in a Console Application. Everything is working well, Windows Application is receiving callbacks etc. But major problem is performance. It is taking 4 times more to process same Job via WCF Request than Manual Upload via MVC Application.
Initially I doubted it is lag in Communication thus I implemented a Stopwatch to find the duration of each step. Surprisingly the Delay is not due to communication lag, it is occurring is the last routine which makes SOAP Requests to External Services. In my opinion this is independent of Mode of Transport of Job from the Client to Server and this also runs in Separate Threads in Custom ThreadPool.
I am using Same API in MVC Application and WCF Service. Logic, Routine everything is same. My Second doubt was whether WCF Halts/Suspends the running threads to process new requests?
Can anybody have insight on what could be the reason? I can provide some more information based on what is required.
Thanks in advance for the Help
I was totally frustrated so though of giving a Try to Host it in IIS7 and It Worked!!! The Performance improved as I hosted it in IIS. Hope this might be helpful to somebody. Please post if anybody realizes the root cause.
精彩评论