DevTeach2004 : ASP.NET Performance. Recommendations and Best Practices
ASP.NET Performance. Recommendations and Best Practices.
Rob Howard.
NET299
These session notes serve primarily to share the content of the session and as a reference for me. They may also provide some value to those interested in the session topics. Some of the information found in these notes may be inaccurate due to my typing errors or a lack of understanding of the subject matter. DevTeach policy is that session material is available online to registered attendees only, so I cannot respond to any requests for session PPTs or source.
Think about performance up front. Performance is iterative.
Client response time: TTLB (time to last byte)
Machine Thoughput. How many client requests can a server handle? # requests/sec, # servers required.
Measure most popular, common paths.
MS Web Application Stress Tool and MS Application Center Test Tool. Latter is part of VS.NET Enterprise, Stress Tool is free, not as nice as latter tool.
Always run stress tools on separate machine. Maxes out server CPU. Use multiple physical clients for heavy load. Simulate different client bandwidth levels. (56K dialup)
Rob demo'd stress testing ASP.NET Forums on localhost and improved preformance by collapsing discussion groups (server side.)
Analyzing ASP.NET PerfMon
CPU % utilization, should be more than 70% or some blocking issue.
Long-term memory objects should not reference short-term memory objects for disposal purposes.
Free MS Memory Profile Available for Download (but need C++ compiler...say what?)
Optimal memory use is larger amount of short-term memory objects and smaller amount of long-term objects.
Check ScottGu's page for past ASP.NET tips and tricks presentation materials.
TIPS and Best Practices
Connection Pooling. Automatic caching/re-use. No need to write any code for this to happen. Always call Close(). On Close() the connection goes back to the pool.
Connection leaks. Perfmon has an ASP.NET Pipeline instance count. Connections count should roughly respond to the pipeline instance count.
Use a single connection string for pooling (other than adding user's name/password.)
Datareader verses DataSet. DataReader with arraylist used as asp.net forums. Dataset uses datareader, good for caching and reuse.
Only return data you need from the database. Use .ExecuteScalar, .ExecuteNonQuery when appropriate.
Check Rob's site for TechEd2004 presentation. Demo of multiple dataset return with single connection.
Do paging at database, not returning entire dataset and page in the control.
Use sprocs. Avoid "sp_ fn_ sys" for procnames, requires lookup in system database.
Biggest bang for the buck is focusing on performance in the database layer.
SQL Profiler to analyze DB activity. Ken England's "MS SQL Server 2000 Performance Optimization and Tuning Handbook."
Think caching first.
Summary: Went long on the overview and approach to performance, ran out of time on the more practical tips and tricks. Still an excellent presentation. Heck, its Rob Howard. 9 out of 10.