views:

281

answers:

2

Hello,

I am trying to create an ASP.NET Web Service which I can use to show the difference between implementing a Web Method asynchronously vs. synchronously. It is sort of a proof-of-concept that I can use to show how writing things asynchronously can make an app more scalable. To make the comparison, I implemented two methods, RunSqlSync and RunSqlAsync . Like this:

[WebMethod]
public int RunSqlSync(string sql)
{
    // call SQL synchronously
}

[WebMethod]
public IAsyncResult BeginRunSqlAsync(string sql, AsyncCallback callback, object state)
{
    // call SQL asynchronously
}

[WebMethod]
public int EndRunSqlAsync(IAsyncResult result)
{

}

I would expect that I would be able to process more concurrent requests by using the Async version of the methods, especially if the SQL call took a while to complete. Unfortunately, for both methods, it seems that I hit a request/sec limit (the limit depends on the latency of the SQL calls) and I am not even close to maxing out my CPU. When I increase the number of requests being sent to the web service (by increase the number of users using in my Ocracoke Load Test), the average response time just increases without changing the actual TPS throughput. I instrumented the Web Service internally to measure the time it takes for a request to complete, and within my code, each individual request is being processed in the same time, regardless of load. This makes me think that ASP.NET is somehow throttling. Does anyone know why this would happen?

+1  A: 

you can set the max pool size in the .net sql connection string call. I believe the default is 20 connections max so if your hitting that then it would only allow those to be used and essentially you would get the same results. Here is an article on connection pooling.

http://www.15seconds.com/Issue/040830.htm

Robert
+1  A: 

Like schwig said, you're probably not running into a bandwidth limitation, you're probably running out of worker threads in your process. Here's the chapter you should read from MS which I find to be enlightening:

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

Dave Markle