I have an ASP.NET 4.0 Web Service that accepts transmission of XML files. In the past (with a different implementation of the same web service) we have tracked the concurrency (# of XML files being received/processed at the same time) using timestamps. I have replicated this behavior in the new version of the web service as such:
In the constructor for the Web Service class I record ConnectionStartTime
using HttpContext.Current.Timestamp
public class MyWebService : System.Web.Services.WebService
{
public MyWebService()
{
ConnectionStartTime = HttpContext.Current.Timestamp
}
}
After I'm done processing the XML file within the WebMethod
I insert the file into a database (recording ConnectionEndTime
) and return the response to the user. I execute the database insert in a new Thread
so the end user doesn't have to wait for the insert to occur to receive their response.
new Thread (() =>
{
insertIntoDatabase(ConnectionStartTime, ConnectionEndTime=Datetime.Now, xmlFile);
}).Start();
return responseToUser;
Now I'm trying to gauge how many concurrent XML transmissions we've reached with two methods:
1. Performance Counters
- ASP.NET Apps v4.0\Requests Executing - This counter peaked at 52.
- ASP.NET Apps v4.0\Requests Queued - This counter peaked at 19.
To me this means I should see a point where we have 33 records with overlapping ConnectionStartTime
and ConnectionEndTime
.
2. Querying Against Timestamps
- In this question I reference the query I'm using to calculate the number of concurrent transmissions based on ConnectionStartTime
and ConnectionEndTime
. These are datetime
fields in a SQL Server database. Note: The query in that question is a reworked version of the algorithm we've been using for the past 3 years to determine concurrency so it may not be 100% correct but the other implementations of the algorithm (Excel macros, etc) have been validated.
My problem is that the two methods never align. The maximum results from querying the timestamps hit 10 while the performance counters suggested the maximum should be 30+. I'm having a hard time locating where the discrepancy is. Am I making a mistake in how I'm recording my timestamps? Does the HttpContext.Current.Timestamp
value not record the beginning of a transmission to the web service?