IIS - 503 service unavailable error - Asked By nishant gautam on 02-Feb-10 02:38 PM

I am on a shared hosting service. These days I am getting 503 error quite frequently. I am not able to know the exact reason. how could I Know the exact reason why it is happening?

I know about rapid fail protection which cause application pool to shut down for a particular number of error in a fixed time. but what type of error these can be for example these are not html errors obviously, not complilation error, then what type of errors/failures can cause application pool shutdown.
I have installed blog on my site and generaly when i view blog pages I get 503 error so what type of error/failure we could think of which can cause application pool to shutdown....

Does this help? - [)ia6l0 iii replied to nishant gautam on 02-Feb-10 03:07 PM

From the technet article titled "503-Service Unavailable (IIS 6.0)", 

1.Check the HTTP.sys error log for information about the error being returned. See Table 11.11   HTTP 503 Errors from HTTP.sys for error descriptions.
2.Check the event logs. Typically, the event logs contain more detailed information about the cause of a 503 error.
3.Verify that health/recycling issues are not causing the error.
4.Check for server binding conflicts.
5.Check the IP inclusion list for errors.

Have you checked all of these?

Also check the Httperr.log file for more info on the actual errors. You can find the file in the following location: %Systemroot%\System32\LogFiles

And check the Event Viewer for System and Application logs . You might have something interesting. (You can launch Event Viewer by typing "eventvwr" in your run menu without quotes and by pressing the Enter key)

Hope this information helps.

nishant gautam replied to [)ia6l0 iii on 02-Feb-10 10:55 PM
i am on shared hosting cant view all these logs- i asked service providers they told me this-
Your web site is using too much CPU, here is the exact error in the logs, it refers to the CPU limit set:
Application pool 'schoolsearch.in v2.0 (Classic)' exceeded its job limit settings.

could you tell me how it could exceed job limit settings...? does this mean something in code is eating up too much resources..??



---
NIshant
nishant gautam replied to nishant gautam on 02-Feb-10 11:00 PM
i am on shared hosting cant view all these logs- i asked service providers they told me this-
Your web site is using too much CPU, here is the exact error in the logs, it refers to the CPU limit set:
Application pool 'schoolsearch.in v2.0 (Classic)' exceeded its job limit settings.

could you tell me how it could exceed job limit settings...? does this mean something in code is eating up too much resources..??

i have  a java script which runs continuously on home page of my site. except that I dont have anything which runs after every few minutes...
Huggy Bear replied to nishant gautam on 02-Feb-10 11:52 PM
This issue is because your application pool has exceeded any of the below setting in the machine.config file

1. Maximum number of threads
2. Maximum running time
3. Maximum memory

Out of these 3 I suspect the third one. That is the maximum memeory allocated for the app pool has been exceeded. If you are storing a lots in your ViewState data, then try reducing it. That could be a major cause. Also check if there are any memory leaks in your asp.net application by using a good .net profiler.

Are you using any kind of threading in your asp.net application, this could also be caused if the thread limit is exceeded.

Are you performing any loop and creating objects like SqlConnection or Streams and not disposing them properly.

Check for the above possibilities in the application.

nishant gautam replied to Huggy Bear on 03-Feb-10 12:24 AM
I am using global.asax file in which I am using

  Private Const DummyPageUrl As String = "http://www.schoolsearch.in/hiturl.aspx"
    'Private Const CONNECTION_STRING As String = "Data Source=(local);Initial Catalog=tempdb;Integrated Security=SSPI;"
    Private Const LOG_FILE As String = "c:\temp\Cachecallback.txt"
    Private Const MSMQ_NAME As String = ".\private$\ASPNETService"
    Private Const DummyCacheItemKey As String = "GagaGuguGigi"
    Private Const DummyCacheItemKey2 As String = "huhuhuhhuhu"

    Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("con").ToString)
    Public Shared _JobQueue As New ArrayList()

    ''' <summary>
    ''' Required designer variable.
    ''' </summary>
    Private components As System.ComponentModel.IContainer = Nothing

    'Public Sub New()
    '    InitializeComponent()
    'End Sub
   
   
    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs on application startup
        RegisterCacheEntry()
    End Sub
   
    ''' <summary>
    ''' Register a cache entry which expires in 1 minute and gives us a callback.
    ''' </summary>
    ''' <returns></returns>
    Private Sub RegisterCacheEntry()
        ' Prevent duplicate key addition
        If HttpContext.Current.Cache(DummyCacheItemKey) IsNot Nothing Then
            Exit Sub
        End If
           
        HttpContext.Current.Cache.Add(DummyCacheItemKey, "Test", Nothing, DateTime.MaxValue, TimeSpan.FromDays(1), CacheItemPriority.NotRemovable, _
         New CacheItemRemovedCallback(AddressOf CacheItemRemovedCallback))
        
         'HttpContext.Current.Cache.Add(DummyCacheItemKey2, "Test", Nothing, DateTime.MaxValue, TimeSpan.FromMinutes(10), CacheItemPriority.NotRemovable, _
         'New CacheItemRemovedCallback(AddressOf CacheItemRemovedCallback2))
    End Sub
        
         'Public Sub CacheItemRemovedCallback2(ByVal key As String, ByVal value As Object, ByVal reason As CacheItemRemovedReason)
         '       System.Diagnostics.Debug.WriteLine("Cache item callback2: " & DateTime.Now.ToString())
         '       hitpage()
         'End Sub


 I have commented all these and even deleted global.asax file . could that be a reason
Huggy Bear replied to nishant gautam on 03-Feb-10 05:20 AM
Amount of data stored in the data Cache could also be a reason, if I am not wrong. Did you try running it after commenting the caching part?
nishant gautam replied to Huggy Bear on 03-Feb-10 05:50 AM
The whole  cache part is already commented....

 have a quick question regarding variables.

Q-1)All variables which I create in a VB file (even public variables , all datasets ) gets destroyed and cleared after page is executed (means page is displayed)  ????

Q-2)variable inside function gets destroyed once function is complete so I dont need to worry but what about public variable which I declare in class scope (so that I can use them in .aspx also) do they also get destroyed once page execution is complete.??

Q-3) while executing any page suppose I am retrieving some data from backend and storing in dataset, could that data be so large that memory threshold gets crossed and application pool gets shutdown..?but in this case 503 error should come only on a  


I am trying dotnet profiler also to keep a track of memory usage. I am running same code on my local machine with dotnet profiler.
live instance and live memory usage remains same but total instances and total memory usage keeps increasing.

some statisctics- when I go from page1 to page2  again to page1 then to page2 and the to page1

                                          page1        page2               page1            page2                page1
total instance                    62,976        84,421              84,316            82,185,               86,720
live instance                      61,620        74,314              75,545            74,845                76,126
Total memory(bytes)        4,096,751    5,829,198        8,183,464        6,300,569        7,512,323
live memory(bytes)           3,705,235    4,437,829        4,871,300        4,478,517        4,603,951

earlier I was using       
 Response.Cache.SetExpires(DateTime.Now.AddDays(1))
 in page 2(statistics are posted after removing this line)


The Application Pool is strictly constrained by certain configuration parameters.
[)ia6l0 iii replied to nishant gautam on 03-Feb-10 10:43 AM
They can be overridden by your applciation configuration file. Those include the Max number of threads, Max running time and Max Memory

Needless to say, the Application Pool would be recycled when you exceed these constraints.

You would have to look at the Application Pools section in your configuration file and edit the cpu limit and the reset interval values.  A sample configuration section is shown below:

<applicationPools>
   <add name="MyAppPool">
     <cpu limit="45000" action="KillW3wp" resetInterval="00:5:00" />
   </add>
   <applicationPoolDefaults>
     <processModel identityType="NetworkService" />
   </applicationPoolDefaults>
</applicationPools>

Hope this information helps.



check you page size, you should reengineer if viewstate is over 2k.