In article I will guide to resolve the “server too busy” error in asp.net. This error is big headache one when you site is running long time smoothly. This error does occur for less no of users most properly.
Why this error is occurred?
There are few no of reasons to occur this error. By the word itself, we can under this error is occurred when server unable to handle the requests. Experts given few reasons,
1. The database query may take long time to respond.
2. No of free threads not enough to IIS to handle the request
3. In your code has memory leaks
4. In your code have infinite loops.
5. Server does not have capabilities to handle huge no of visitors.
• If first one is reason for this error, then you may to review your query using SqlProfiler and fix the query to response quickly.
• If your code has memory leaks or infinite loops, then you have to review your code and have to fix.
• The second is most important on for this error. But we can fix this case easily with webconfig file.
When you are take look your web config file, there is a tag call httpRuntime like following normally.
<httpRuntime executionTimeout="3600" maxRequestLength="4096" />
More details about httpRuntime here
To resolve this error with web config, we have to override the following attributes in config.
Specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET.
This time-out applies only if the debug attribute in the compilation element is False. If the debug attribute is True, to help avoiding application shut-down while you are debugging, do not set this time-out to a large value. The default is 110 seconds.
Specifies the limit for the input stream buffering threshold, in KB. This limit can be used to prevent denial of service attacks that are caused, for example, by users posting large files to the server. The default is 4096 KB
Specifies the minimum number of free threads to allow execution of new requests. ASP.NET keeps the specified number of threads free for requests that require additional threads to complete processing. The default is 8.
Specifies the minimum number of free threads that ASP.NET keeps available to allow execution of new local requests. The specified number of threads is reserved for requests that are coming from the local host, in case some requests issue child requests to the local host during processing. This helps to prevent a possible deadlock with recursive reentry into the Web server. The default is 4.
(API definition from MSDN)
Now we have to override values for above attributes. Once override web config file will look followings,
<httpRuntime enableVersionHeader="false" executionTimeout="72000" maxRequestLength="4096" minFreeThreads="72" minLocalRequestFreeThreads="88" useFullyQualifiedRedirectUrl="false" />
Just override your production web configuration file with above modfied file. Now see your server to able to handle more request than earlier.But your web server does not enough memory or CPU, then you have to upgrade that to support to handle to more request.
In tips I have given solutions to “server too busy” error in asp.net.i hope this is help to you all.