Low Traffic Website - Slow Initial Load - asp.net

I have a problem with my website and I think it's related to IIS recycling the app pool or shutting down the app after 20 mins of inactivity. As it is a low traffic site, when I first browse to the site the initial load can take up to 30 seconds, then after that it is very fast. If i then come back to the site say a few hours later I get the slow load time again. I'm sure it's something to do with the app pool shutting down after 20 mins of inactivity?
Another problem is that I am hosting via a hosting company so have no direct access to manipulate IIS at all. Does anyone know how I can keep my app alive so I don't suffer from the initial slow load speed issues?

You could setup a service to issue a request every few minutes to your site which can double as monitoring your site to ensure it's still running. You probably don't have access to the application pool configuration I assume.

Related

How to change idle timeout asp mvc app on my shared hosting provider?

I have a site on a shared hosting provider. My site timeouts when on idle and can take up to 40 seconds to start up again, I want to increase the idle timeout. Under manage - Dedicated IIS application Pool, the idle timeout is set to 5 minutes I want to increase it, I called my provider and they said I am unable to change the settings with a shared hosting account. I was thinking if there was another way Like the web.config folder to increase the timeout time?
The app pool is likely being recycled. There's nothing you can do about this on a shared hosting service. What you can do is send pings to the web server every N minutes. If GoDaddy recycles the app pool every 5 minutes, then send a ping to your website every 4 minutes. Doing this should extend the timeout an additional 4 minutes. If you always do this, it should not recycle unless explicitly called (or unless the host has some other recycle in place).
Optionally, you can use a monitoring service that pings and reports on your server. Here are two that may be of use to you: https://uptimerobot.com/ https://www.pingdom.com/
Uptime services that I've tried didn't actually send HTTP requests to the web app so it didn't help in keeping it alive. However, I found a nice feature in Application Insights called Availability which lets you create recurring tests that actually send GET requests to your website, thus preventing it from recycling.
I explain it more in my blog post here.
Open task scheduler on your computer
Create a scheduled task to run every 4 minutes
Have it run a powershell command invoke-webreqest to your site.
It'll have the effect of someone visiting your site every 4 minutes.

web app slow performance when leave idle for some time

We have a web application deployed on IIS 7.5 target framework 4.0
the application perform slow when leave idle for few minutes for first time and then perform as expected this happened each time application is idle.
With the help of fiddler I found its TCP/IP connection which is taking time about 21 secs whilein subsequent calls this time is 0.
The Idle time out is also set high and connection time out is also high in the IIS settings.
server is - Windows 2008 R2.
there is nothing in the event viewer related to the website.
we used form authentication but the time out for that is also set about 10 hours in the config file.
Can anybody point me to the setting with is affecting the response time after the app is idle for some time.
Note - this was working proper when deployed withing the LAN but this problem starts when deployed out of the LAN or in separate domain.
Problem
here is the problem in IIS app pool idle time out, its by default set to 20 minutes, after 20 minutes app pool shutdown if no request within 20 minutes,
when any request comes after 20 minute its again start,
The problem is that the first visit to an app pool needs to create a new w3wp.exe worker process which is slow because the app pool needs to be created, ASP.NET or another framework needs to be loaded, and then your application needs to be loaded. so it may take time 20-30 seconds or depends on the application content size.
Solution
so to avoid this type of delay we need to set the idle time out to 0.
now it will always load fast.
app pool setting
The IIS application pool is shut down after 30 minutes of inactivity. After that, when you make a request IIS basically has to start the website up again, which leads to the behavior you are describing. You can change the idle time of your website in IIS though to avoid it.
You could also look into the Auto-Start feature of the 4.0 framework.
Well, a bit late, but may help someone else. I had the same problem, nothing in the logs, spent days, then looking at the network adapter properties / configuration / power management - Allow computer to shut down save power was checked. Unchecked and the problem was solved.

ASP.NET web app slow response after a pause

I'm building a web app using ASP.NET MVC and MS SQL Server CE and deploying it to a shared hosting. Every time I approaching my site after a pause (half an hour) it performs very slow. It takes about 40 seconds to load the first page. After this every page opens quickly.
Please advice what may cause the problem and how to solve it.
Thanks
Update: It appeared that after a pause in visiting (10-20 min) the site is loaded from the server hard drive not memory. That is why it was so slow. Possible solutions are increase site visits, move to a virtual server or ping the home page regulary.
My hosting provider has an option for pinging besides some solutions are described here c# ping a website? (keep-alive service)
If the worker process is not processing requests it will shut down the worker process after the specified number of minutes. (if configured)
Not sure what version of IIS you are using but look into "Idle Time-out (minutes)". IIS 7 specific info below...
http://technet.microsoft.com/en-us/library/cc771956(WS.10).aspx
As a paliative, set your app to recycle only after a long period of inactivity.
See Configure an Application Pool to Recycle at a Scheduled Time (IIS 7)

Overcome compilation(?) pause on *secondary* initial ASP.Net application startup?

After deploying an ASP.Net application to a new server, the first user to hit the app gets a long pause, presumably because the app is performing its initial compilation. However, this pause seems to also also occur after the application has timed out and unloaded itself from memory.
The first compilation would be tolerable as it only happpens once, but the 2nd one seems to me like it should be unnecessary....is there a workaround to address this issue? It would be nice to be able to extend the application timeout, but I only see a way to extend the session timeout, which I would rather not do, as this would keep all user sessions in memory for a long period of time.
That's IIS shutting down the worker process - the default is a 20 min idle time. In IIS6, you can configure the app pool and turn off the Idle timeout (on Performance tab). In IIS7, it's in the Advanced Settings.
A common way (though looks hackish to me) to keep the worker process alive is to have some program issue web requests to some URL in the application on a regular basis.
You can reduce the initial startup time by precompiling the ASP.NET app with aspnet_compiler.exe. This won't reduce the initial request time to zero (it'll still need to create the worker process and do other housekeeping.) but it'll noticeably reduce it.
I did find some recommended settings for the App Pools in IIS. The intended outcome of these settings is to reduce the number of times your application needs to go through the startup cycle. These settings should apply to IIS 6 as well as IIS 7:
Recycle Worker Process: Disable. Use this only if you have multiple websites and are trying to isolate processes.
Shutdown worker processes after being idle for (time in minutes): Disable unless you are sharing resources on your server. With this setting disabled, your website should not unload, ensuring that startup time for your site is as minimal as possible.

Session timeouts in asp.net on a dedicated server

I have a asp.net website hosted in the dedicated server.I'm using web.config to handle the session timeouts and that is 60 minutes.I did the following settings on the dedicated server (windows server 2003 and IIS 6.0 versions)
In the default web site property of IIS-->ASP.net tab-->Edit configuration-->Session timeouts -->60
In the application pool The session timeout has been extended to 60.
Recycling worker process has been set to 60 in the application pool.
I can get this work correct on my local system the problem is on the dedicated server(Goddady). No customer support is available for this problem
It will be also fair if the session timeout is infinity too.
But the timeout occurs after every 20 minutes if the webform is kept idle. How to get rid of this? I have a guess that the idle timeout is overriding the session timeout as I googled around but have not found a solution for this
please help me........
Thanks,
Prabha
We had the same problem on a hosted server, and decided that rather than fighting with the hosting company we would use some javascript on a timer to execute an AJAX request to the server to reset the session if it was about to expire.
This site (PreventTimeout) is very close to what we do.
I know this doesn't answer your question directly, but it has been a good workaround for us.
If you recycle the application pool every 60 minutes, then (assuming your sessions die when the pool recycles) a session started 10 minutes before the pool recycles will only last 10 minutes.
On average, you'd expect a session to last 30 minutes.

Resources