Precompilation In ASP.NET 2.0

J

J055

Hi

I have a small ASP.NET 2.0 application running in a production environment.
The whole application has been precompiled including the ASPX and ASCX
pages.

The problem I have is that the application is only used periodically, say
once a day for an hour or so, but there's no real consistency. The first
page load of the day is very slow, sometimes 20/30 seconds. This looks bad
because the application was updated from classic ASP and VBscript which
still seems to run very fast.

The hardware is more than capable. I guess there are some tweaks to the
application pool settings that can be made. Are there any downsides to
unchecking 'Recycle worker processes' or 'Shutdown worker process after
being idle'? Presumable the default settings are there for a reason. Is
there anything else that can be done to avoid the slow start. I've struggled
to find any documentation on this.

Many thanks
Andrew
 
S

Steven Cheng[MSFT]

Hello Andrew,

Thank you for posting here.

From your description, I understand you've developed an ASP.NET 2.0 site
and after deploy it(precompiled) to the webserver, you found it will always
suffer slow performance(due to dynamic compilation) on the firtst requests,
correct?

As for the procompilation, are you doing the precompiling through "Publish
WebSite" option in visual studio 2005? If so, have you choosed to make the
website "updatable" in the publish website's settings? By default, the
publish website will make the website updatable, that means the web pages
and usercontrols' aspx/ascx template file is not precompiled and remain
their original contents. Therefore, at runtime, the first time a page or
usercontrol is requested, the ASP.NET runtime still need to dynamically
compile it , this make the first time load expensive.

If you do not quite care the ability to edit the aspx or ascx file, you can
just precompile the website with "updatable" option unchecked. Thus, all
the aspx /ascx template file are also precompiled(all the assemblies in bin
dir) and at runtime, the ASP.NET runtime can eliminate the first time
dynamic compilation overhead. You can have a test on your side to see
whether this helps.

As for the IIS "recycle worker process" or "shut down worker process after
being idle" for a certain period, these settings are just for the server's
performance consideration. It is unnecessary to keep a worker process in
memory if it no longer processing any incoming requests. Surely, if you
feel that it is necessary to make a certain ASP.NET worker process always
keeping alive regardless of the idle time, you can create an separate
Application Pool in IIS and uncheck the 'Shutdown worker process after
being idle' option.

Hope this helps some. If there is anything unclear or any other information
you want to know, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial

response from the community or a Microsoft Support Engineer within 1
business day is

acceptable. Please note that each follow up response may take approximately
2 business days

as the support professional working with you may need further investigation
to reach the

most efficient resolution. The offering is not appropriate for situations
that require

urgent, real-time or phone-based interactions or complex project analysis
and dump analysis

issues. Issues of this nature are best handled working with a dedicated
Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at

http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

J055

Hi

The only thing I'm interested in is the first hit after the application has
been idol for a while. The application runs fine after it's started. The
problem for me is that it's the first hit after 24 hours which is most
important to me. This is clearly a ASP.NET/IIS issue. The whole application
is compiled and pages are not updatable. The MSDN documentation about
performance do not address these issues. I can't see what else I can do to
stop this.

Thanks
Andrew
 
S

Steven Cheng[MSFT]

Hi Andrew,

Thanks for your response.

Based on your further description, I've got that the application suffering
the slow startup performance issue is already precompiled as "nonupdatable"
mode. In such case, we need to look for other factors which may cause the
slow startup at application's initializing time. As you mentioned the IIS
application pool's " shutdown worker processes after being idle for(time in
minutes) option, does it helps keep your web application quickly responding
if you uncheck this option? If so, I can conclude that there is some
application wide initializing code or operations that cause the startup
time consuming. Since the pages/user controls have been precompiled, I'm
wondering the following things in your application:

1. XML Serizalization/Deserialization or programmatic XSLT transformation
processing, XML Serialization and XSLT transformation will also cause the
runtime to compile and generate dynamic types/assemblies.

2. Complex initializing code in the ASP.NET application's global
Application_Start event. This event fires when the ASP.NET
application/appdomain starts.

Is either of the above ones apply to your web application?

Also, after long period(24 hours as you mentioned), is the slow startup
behavior occurs when you try visiting any page in the application or just
when visit some particular pages in the application? This can help isolate
the performance issue case to page or component specific.

For such performance troubleshooting/tuning issue, it would be a bit hard
to rapidly address the underlying cause due to the limitation of newsgroup
interface. Anyway, please feel free to let me know if you need any further
information or assistance, we'll be glad to help.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

J055

Hi Steven

Not sure if you're still watching this thread becuase I know it's been a
while since your last message. Please see my responses below.
Based on your further description, I've got that the application suffering
the slow startup performance issue is already precompiled as
"nonupdatable"
mode. In such case, we need to look for other factors which may cause the
slow startup at application's initializing time. As you mentioned the IIS
application pool's " shutdown worker processes after being idle for(time
in
minutes) option, does it helps keep your web application quickly
responding
if you uncheck this option? If so, I can conclude that there is some

Unchecking this seems to help performance for a while longer but after a few
hours the application is sluggish again on the first page load.
application wide initializing code or operations that cause the startup
time consuming. Since the pages/user controls have been precompiled, I'm
wondering the following things in your application:
1. XML Serizalization/Deserialization or programmatic XSLT transformation
processing, XML Serialization and XSLT transformation will also cause the
runtime to compile and generate dynamic types/assemblies.

Not used in this application
2. Complex initializing code in the ASP.NET application's global
Application_Start event. This event fires when the ASP.NET
application/appdomain starts.

No code in the Application_Start event.
Is either of the above ones apply to your web application?

No, these are small and simple applications. I'm supprised no one else
reports this type of behaviour.
Also, after long period(24 hours as you mentioned), is the slow startup
behavior occurs when you try visiting any page in the application or just
when visit some particular pages in the application? This can help isolate
the performance issue case to page or component specific.

It appears to affect any pages, even ones where there is only a label and
textbox control in the page and a small event fired to log on to the system.
For such performance troubleshooting/tuning issue, it would be a bit hard
to rapidly address the underlying cause due to the limitation of newsgroup
interface. Anyway, please feel free to let me know if you need any further
information or assistance, we'll be glad to help.

I'm assuming that most ASP.NET apps have high demand so that the
applications resources are always kept in memory. Is it that I only use the
application once a day the main cause of the problem? I have tried different
hardware and still see similar performance problems. Can you point me to any
documentation which may help me optimize IIS to run ASP.NET apps?

Thanks
Andrew
 
S

Steven Cheng[MSFT]

Thanks for your followup Andrew,

Sure, we're always monitoring the issues here :).

Yes, there does exists some reference and best practice about tuning the
performance of ASP.NET web application. Here are some of the articles in
MSDN:


#10 Tips for Writing High-Performance Web Applications
http://msdn.microsoft.com/msdnmag/issues/05/01/ASPNETPerformance/default.asp
x

#Developing High-Performance ASP.NET Applications
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconDevelopingHigh-Per
formanceASPNETApplications.asp?frame=true

#Checklist: ASP.NET Performance
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/
scalenetcheck03.asp

#Monitoring ASP.NET Application Performance
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconmonitoringaspnetap
plicationperformance.asp?frame=true


However, I think the problem in your scenario should be caused by some more
specific causes and those general guidlines won't quite apply(though you
can have a look for reference).

Also, according to the following symptoms you mentioned:

===================
Unchecking this seems to help performance for a while longer but after a
few
hours the application is sluggish again on the first page load.

It appears to affect any pages, even ones where there is only a label and
textbox control in the page and a small event fired to log on to the system.
===================

The delay and slow performance you met is still likely due to the
application/pages' startup compilation/initialization. I suspect that your
ASP.NET web application has ever restarted during the period you visit the
application. This will make all the pages and resources be recompile and
reinitialized. I suggest you add some code to into your ASP.NET
application's Application_Start or Application_End event (in the
global.asax) and write some entry into the eventlog there. Thus, you can
check whether your web application has ever been restarted any times furing
your multiple visits to the application.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Joined
Mar 18, 2008
Messages
1
Reaction score
0
Andrew

Did you ever get to the bottom of this as I am having exactly the same problem.

Any advice would be very much appreciated.

Thanks in advance.
 
Joined
Nov 13, 2007
Messages
4
Reaction score
0
I had the same problem. The reason is that the application domain times out every 20 mins if there is no activity, the first request after the timeout can force a recompile and reload of cache. Changing some settings in the machine.config file will solve the problem; unfortunately for me my hosting provider would not allow me to make this change. I found this utility to be useful.


http://www.spikesolutions.net/ViewSolution.aspx?ID=c2b7edc0-5de1-4064-a432-05f6eded3b82



Essentially it "Pings" my home page every few mins so the application domain does not time out. The utility can also be configured to ping more than one page so that auxiliary pages are fast too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top