user544511
user544511

Reputation: 759

How to configure WCF to handle lots of concurrent users?

We are developing a multi-tenant system which is utilizing WCF + SQL Azure for data access. Basically we have WCF service hosted in Azure to which our client connects and then this WCF service queries SQL database for data and returns data to client. Everything else is working just fine but we have some odd performance problems with channel between client and WCF.

It seems that if there are enough concurrent users using our service, WCF will start to block connections. And by "enough" I mean something like 20-30 users which are making approximately 1 query per second, which in turn should be something that I would expect WCF to be able to handle without problems. The time spent in WCF service per query is less than 1 second, usually 100 to 200ms.

The reasons why we believe WCF is blocking connections are:

  1. We are logging both time spent in WCF service and the time that WCF call takes in total, and there is substantial difference between these. For example, time spent in WCF service could be 100ms and the total time (from client's perspective) could be 5000ms or even 10000ms.
  2. Client could be running just fine until it hits first spike. Subsequential calls will either take very long time or even time out.
  3. Sometimes client cannot connect to service at all.

WCF service is using netTcpBinding and following settings are configured:

ServicePointManager.DefaultConnectionLimit = 1024;
netTcpBinding.MaxConnections = 1024;
netTcpBinding.SendTimeout = 5 minutes
netTcpBinding.ReceiveTimeout = 5 minutes
serviceThrottlingBehavior.MaxConcurrentCalls = 1024;
serviceThrottlingBehavior.MaxConcurrentInstances = 1024;
serviceThrottlingBehavior.MaxConcurrentSessions = 1024;

I'm not sure if this is important but all clients are behind same IP address. Also, channel is opened and closed for each request (mostly because Azure closes connections after they have been idle for 1 minute and we haven't been able to figure out how to handle this in robust way).

Any ideas?

Following questions are related to this but they really don't provide an answer: How to scale SQL azure? SQL Azure vs WCF Performance

Upvotes: 1

Views: 1072

Answers (1)

Thiago Custodio
Thiago Custodio

Reputation: 18387

Enable Diagnostics in WCF, it will help you identify problems.

Take a look once again to your throttling config again:

http://msdn.microsoft.com/en-us/library/ms731379.aspx

http://msdn.microsoft.com/en-us/library/vstudio/ms735114(v=vs.100).aspx

http://www.codeproject.com/Articles/33362/WCF-Throttling

In case you are transfering large objects, change the default TransferMode to Streammed.

Upvotes: 1

Related Questions