Monday, 11 September 2017

SQL Server Is Too Busy...

SQL Server Is Too Busy...
Quick Tips and tricks to tackle with performance

What?

Today I will guide to resolve the “server too busy” error in asp.net.

Why?

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 and go busy out while trying to do so.following could be the response which could be the reason of slow down the server.

1.    QUERY RESPONSE:    The database query may take long time to respond.
2.    IIS RESPONSE:             No of free threads not enough to IIS to handle the request
3.    MEMORY RESPONSE:In your code has memory leaks
4.    LOOP RESPONSE:       In your code have infinite loops.
5.    VISITOR RESPONSE:  Server does not have capabilities to handle huge no of visitors.

Solution?

•    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.
1.    executionTimeout
2.    maxRequestLength
3.    minFreeThreads
4.    minLocalRequestFreeThreads



executionTimeout
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.
maxRequestLength
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
minFreeThreads
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.
minLocalRequestFreeThreads
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.

Conclusion

In tips I have given solutions to “server too busy” error in asp.net.i hope this is help to you all.

No comments:

Post a Comment

Print Only Grid View in ASP.net

ASP.net How to Print Only GridView < div id ="gridviewDiv" >   < asp:GridView ID ="gridViewToPri...