2005-10-24

Debugging timeouts in a SOA/Web environment

In a Service Oriented Architecture (SOA), having some webservice methods that consume more than a minutes time, timeout can be a problem.

In this scenario there is also a web site acting as the webservice client. The webservice is getting its data from a database.

We know there is a timeout, but where?
a) Could be the connection to the database from the webservice.
b) Could be the connection between the webservice and the webservice client.
c) Could be a browser timeout.
d) Could be a .NET Framework/ASP.NET timeout.

a. The connection to the database
The timeout of a query can be set by a propery on the ADO.NET Command object. The default is 30 seconds.

OleDbCommand dbcmd = new OleDbCommand();
dbcmd.CommandTimeout = 600; //10 minutes should be enough?

b. The connection to the webservice
The timeout of the http connection of a synchronous call to a web service has a default timeout of 100 seconds. This can be set by a property on the web service proxy. You can set it in the constructor of the webservice proxy (remember that this may me overwritten when you update your webservice reference):

public WSMyWebservice() {
this.Credentials = System.Net.CredentialCache.DefaultCredentials;
this.Url = "http://localhost/webservice/WSMyWebservice.asmx";
this.Timeout = 450000; //wait for 7.5 minutes
}

c. The browser timeout
Not covered in this topic.

d. .Net Framework / ASP.NET timeout
There are a few places the timeout can be set in machine.config.
The executionTimeout in the httpRuntime section can be increased. In the .NET Framework versions 1.0 and 1.1, the default is 90:
<httpruntime
maxrequestlength="4096"
usefullyqualifiedredirecturl="false"
minfreethreads="8"
minlocalrequestfreethreads="4"
apprequestqueuelimit="100"
enableversionheader="true"
executiontimeout="90">

In the processModel section there are several timeouts that can be set:
<processmodel
username="machine"
password="AutoGenerate"
timeout="Infinite"
enable="true"
idletimeout="Infinite"
shutdowntimeout="0:00:05"
requestlimit="Infinite"
requestqueuelimit="5000"
restartqueuelimit="10"
memorylimit="60"
webgarden="false"
cpumask="0xffffffff"
loglevel="Errors"
clientconnectedcheck="0:00:05"
comauthenticationlevel="Connect"
comimpersonationlevel="Impersonate"
responsedeadlockinterval="0:03:00"
maxworkerthreads="20"
maxiothreads="20">

The above should show the default settings, although I can't guaratee it. The setting that may be changed to avoid timeout is the responseDeadlockInterval. MSDN states the following about the setting: Specifies the time interval, in standard process model format (hr:min:sec), after which the process is restarted, if the following conditions are met: 1) There are queued requests, and 2) There has not been a response during this interval.

No comments:

Post a Comment