Simon
Simon

Reputation: 93

WCF Restful service bad performance

My wcf restful service manages to serve only 2 requests/sec!

detailed:

I've created a wcf restful service which exposes only one method via GET verb. The method makes no logic, and returns immediately.

I've also created a test client in order to check the service throughput and performance, which makes requests by WebHttpRequest.

The service was able to process only 2 requests/sec!

I also made a request to the service through my browser, and the same result: 500ms for one request.

Then I changed the service binding to netTcpBinding and the service was able to process around 2000 requests/sec.

The service was running under a windows service, and hosted by WebServiceHost with WebHtppBinding.

good to mention that both client and the service was running in the same server.

Does it make any sense that wcf restful service has such poor performance?

Would Appreciate any help. Thanks.

Upvotes: 2

Views: 2103

Answers (1)

Drew Marsh
Drew Marsh

Reputation: 33379

No, it makes no sense and probably points to a problem with your testing. How was your REST test client written? Are you aware that, by default, .NET will only allow two open connections to any domain for a "regular" .NET process? It's increased to ten automatically for ASP.NET apps.

That information is documented here in ServicePointManager.DefaultConnectionLimit. You can increase this programatically or through config by adding a higher limit for the domain you're trying to connect to. Config wise this would look something like this:

<system.net>
    <connectionManagement>
        <add address="www.myserver.com" maxconnection="20" />
    </connectionManagement>
</system.net>

You can open up connections for all domains using address="*" if that's your desire.

As for the delay you're seeing, it could be the result of other features that are on by default such as UseNagleAlgorithm or, if your POST'ing, Expect100Continue.

Upvotes: 4

Related Questions