Nine tips for a healthy "in production" ASP. NET application

Source: Internet
Author: User

Referred from: http://blogs.msdn.com/dougste/archive/2006/04/05/568671.aspx

 

The following are based on problems I see people having every day in production ASP. NET systems.

1. Before you go into production, long before, plan, specify, effecect, design, code and test for your application to meet your requirements for performance, scalability, monitorability, diagnosability. if your requirements are anything like my requirements they equal a quiet life and long coffee breaks. as a starting point the patterns and practices guide Improving. NET Application Performance and Scalability provides an excellent starting point.

2. Ensure that the debug = "false" on the <compilation> element in the web. config file of each and every ASP. NET application on the server. the default during development is "true" and it is a common mistake to allow this development time setting to find its way onto production servers during deployment. you don't need it set to true in production and it often leads to memory overhead and inefficiencies.

3. Wherever possible strong name and install to the global assembly cache (GAC) any assemblies that are used by more than one ASP. NET application. this will reduce memory consumption. in ASP. NET 1.1, do not deploy strong named assemblies to the BIN directory (I. e. if they are strong named make sure you DO put them in the GAC ). note that if assemblies are going in the GAC they need to be designed to operate in the shared AppDomain and you have to trust whoever wrote them.

4. If your ASP. NET application CILS web services be aware that the default configuration of HttpWebRequest allows only 2 concurrent outgoing HTTP connections to a participant endpoint at a time (to comply with the specification ). for example if you have 25 concurrent ASP. NET request going on, all making web service callto the same web service, only two will be actually be doing anything. misconfiguration of this causes major scalability headaches. start by reading this article.

5. Be careful using things that generate dynamic assemblies behind the scenes. these can include RegEx, transform and XmlSerializer. for example if you create XmlSerializers using contructors that are supported ented as "for internal use only" you will get into trouble because the dynamic assemblies that are created do not get cached and re-used. in a production system this can lead to major memory leaks and bring a server down. for RegEx and your transform, try to reuse them wherever you can.

6. In IIS6 make good use of application pools and configure their performance and health monitoring capabilities sensibly. you don't have to have all your applications configured to run in the DefaultAppPool. putting applications into different application pools allows you to do things like isolate an application that has particle memory usage or stability issues, or allow one particle application to use a version of. NET runtime that your other applications are not currently compatible. you shoshould also pay attention to the configuration of application pools. by default application pools are configured to recycle after 1740 minutes. this is 29 hours. this means that your application pool might recycle in the middle of the night one day and then in the middle of your peak online shopping time the next day. as a better alternative, configure the application pool to recycle at a specific (quiet) time of day.

7. Keep an eye on your event logs. this is where important and critical messages get logged. there is a good list available for ASP. NET. note that some of the most importand ones to watch out for (like 1000 and 1003) are only applicable if you are using IIS5 or using IIS6 in IIS5.0 compatability mode. if you are using IIS6 in native mode then the management of the process hosting ASP. NET code is taken over by IIS6 itself and the aspnet_wp.exe worker process is no longer used. in that case IIS6 will log events relating to application pool recycles and terminations. it is important to note however that IIS does not log all such events by default. this article explains how to configure what events are logged. the default value for the metabase value LogEventOnRecycle is 137 which means it only logs an event for recycles due to defined memory thresholds being reached (by default there are none) or due to an elapsed time having passed (by default 1740 minutes ). I always recommend setting this to 255 for all application pools.

The other thing that sometimes happens when you start looking at event logs is that you discover that your application developers have been over enthusiastic in spewing out events that or often not very interesting. it is important to log events when things go wrong by be aware that you can sometimes flood the event log thus masking important messages. I wocould recommend creating your own event log when you install the application and log your events to that. also consider giving your application retriable "levels" of event log. so by default you wowould only log events when something really bad happens but you build in the facility to increase the verbosity and detail of the events when you are investigating a specific issue. there are a number of predefined logging and tracing facilities around like the logging application block and log4net.

8. Monitor performance from time to time, especially in the early weeks after "go live ". things may have gone great during all your performance and scalability testing (you did do performance and scalability testing right ?) But the real world is always different. A very useful article to get started is ASP. NET Performance Monitoring, and When to Alert Administrators. it is amazing how often it is discovered after a system has gone live that it is using huge amounts of memory or throwing a ridiculous number of limits.

9. Deploy updates to your applications at an appropriate time of day. it makes sense deploy updates to your site at a time when traffic is low, like 3 am. of course custom web sites (especially internet facing ones) are live 24 hours per day but ever site has its quiet times. I also recommend stopping the application pool (or IIS in the case of IIS5), deploying all your updates and restarting the application pool/IIS. although ASP. NET shadow copying allows the "hot" deployment of assembly and page updates these will generally trigger an application restart within the worker process or application pool. that's all very well if your application has a normal memory footprint of 20 Mb and is the only application on the server but what if it uses 300 Mb and the other applications use 700 Mb. in "steady state" that is fine but if the 300 Mb application goes through a restart this cocould temporarily push the overall memory usage in the process beyond a critical level.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.