Friday, December 23, 2011

Improving .NET Application Performance and Scalability

Design Considerations

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifConsider security and performance.
Ff647706.checkbox(en-us,PandP.10).gifPartition your application logically.
Ff647706.checkbox(en-us,PandP.10).gifEvaluate affinity.
Ff647706.checkbox(en-us,PandP.10).gifReduce round trips.
Ff647706.checkbox(en-us,PandP.10).gifAvoid blocking on long-running tasks.
Ff647706.checkbox(en-us,PandP.10).gifUse caching.
Ff647706.checkbox(en-us,PandP.10).gifAvoid unnecessary exceptions.

Threading

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifTune the thread pool by using the formula to reduce contention.
Ff647706.checkbox(en-us,PandP.10).gifConsider minIoThreads and minWorkerThreads for burst load.
Ff647706.checkbox(en-us,PandP.10).gifDo not create threads on a per-request basis.
Ff647706.checkbox(en-us,PandP.10).gifAvoid blocking threads.
Ff647706.checkbox(en-us,PandP.10).gifAvoid asynchronous calls unless you have additional parallel work.

Resource Management

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifPool resources.
Ff647706.checkbox(en-us,PandP.10).gifExplicitly call Close or Dispose on resources you open.
Ff647706.checkbox(en-us,PandP.10).gifDo not cache or block on pooled resources.
Ff647706.checkbox(en-us,PandP.10).gifKnow your application allocation pattern.
Ff647706.checkbox(en-us,PandP.10).gifObtain resources late and release them early.
Ff647706.checkbox(en-us,PandP.10).gifAvoid per-request impersonation.

Pages

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifTrim your page size.
Ff647706.checkbox(en-us,PandP.10).gifEnable buffering.
Ff647706.checkbox(en-us,PandP.10).gifUse Page.IsPostBack to minimize redundant processing.
Ff647706.checkbox(en-us,PandP.10).gifPartition page content to improve caching efficiency and reduce rendering.
Ff647706.checkbox(en-us,PandP.10).gifEnsure pages are batch compiled.
Ff647706.checkbox(en-us,PandP.10).gifEnsure debug is set to false.
Ff647706.checkbox(en-us,PandP.10).gifOptimize expensive loops.
Ff647706.checkbox(en-us,PandP.10).gifConsider using Server.Transfer instead of Response.Redirect.
Ff647706.checkbox(en-us,PandP.10).gifUse client-side validation.

Server Controls

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifIdentify the use of view state in your server controls.
Ff647706.checkbox(en-us,PandP.10).gifUse server controls where appropriate.
Ff647706.checkbox(en-us,PandP.10).gifAvoid creating deep hierarchies of controls.

Data Binding

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifAvoid using Page.DataBind.
Ff647706.checkbox(en-us,PandP.10).gifMinimize calls to DataBinder.Eval.

Caching

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifSeparate dynamic data from static data in your pages.
Ff647706.checkbox(en-us,PandP.10).gifConfigure the memory limit.
Ff647706.checkbox(en-us,PandP.10).gifCache the right data.
Ff647706.checkbox(en-us,PandP.10).gifRefresh your cache appropriately.
Ff647706.checkbox(en-us,PandP.10).gifCache the appropriate form of data.
Ff647706.checkbox(en-us,PandP.10).gifUse output caching to cache relatively static pages.
Ff647706.checkbox(en-us,PandP.10).gifChoose the right cache location.
Ff647706.checkbox(en-us,PandP.10).gifUse VaryBy attributes for selective caching.
Ff647706.checkbox(en-us,PandP.10).gifUse kernel caching on Microsoft® Windows Server™ 2003.

State Management

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifStore simple state on the client where possible.
Ff647706.checkbox(en-us,PandP.10).gifConsider serialization costs.

Application State

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifUse static properties instead of the Application object to store application state.
Ff647706.checkbox(en-us,PandP.10).gifUse application state to share static, read-only data.
Ff647706.checkbox(en-us,PandP.10).gifDo not store single-threaded apartment (STA) COM objects in application state.

Session State

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifPrefer basic types to reduce serialization costs.
Ff647706.checkbox(en-us,PandP.10).gifDisable session state if you do not use it.
Ff647706.checkbox(en-us,PandP.10).gifAvoid storing STA COM objects in session state.
Ff647706.checkbox(en-us,PandP.10).gifUse the ReadOnly attribute when you can.

View State

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifDisable view state if you do not need it.
Ff647706.checkbox(en-us,PandP.10).gifMinimize the number of objects you store in view state.
Ff647706.checkbox(en-us,PandP.10).gifDetermine the size of your view state.

HTTP Modules

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifAvoid long-running and blocking calls in pipeline code.
Ff647706.checkbox(en-us,PandP.10).gifConsider asynchronous events.

String Management

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifUse Response.Write for formatting output.
Ff647706.checkbox(en-us,PandP.10).gifUse StringBuilder for temporary buffers.
Ff647706.checkbox(en-us,PandP.10).gifUse HtmlTextWriter when building custom controls.

Exception Management

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifImplement a Global.asax error handler.
Ff647706.checkbox(en-us,PandP.10).gifMonitor application exceptions.
Ff647706.checkbox(en-us,PandP.10).gifUse try/finally on disposable resources.
Ff647706.checkbox(en-us,PandP.10).gifWrite code that avoids exceptions.
Ff647706.checkbox(en-us,PandP.10).gifSet timeouts aggressively.

COM Interop

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifUse ASPCOMPAT to call STA COM objects.
Ff647706.checkbox(en-us,PandP.10).gifAvoid storing COM objects in session state or application state.
Ff647706.checkbox(en-us,PandP.10).gifAvoid storing STA components in session state.
Ff647706.checkbox(en-us,PandP.10).gifDo not create STA components in a page constructor.
Ff647706.checkbox(en-us,PandP.10).gifSupplement classic ASP Server.CreateObject with early binding.

Data Access

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifUse paging for large result sets.
Ff647706.checkbox(en-us,PandP.10).gifUse a DataReader for fast and efficient data binding.
Ff647706.checkbox(en-us,PandP.10).gifPrevent users from requesting too much data.
Ff647706.checkbox(en-us,PandP.10).gifConsider caching data.

Security Considerations

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifConstrain unwanted Web server traffic.
Ff647706.checkbox(en-us,PandP.10).gifTurn off authentication for anonymous access.
Ff647706.checkbox(en-us,PandP.10).gifValidate user input on the client.
Ff647706.checkbox(en-us,PandP.10).gifAvoid per-request impersonation.
Ff647706.checkbox(en-us,PandP.10).gifAvoid caching sensitive data.
Ff647706.checkbox(en-us,PandP.10).gifSegregate secure and non-secure content.
Ff647706.checkbox(en-us,PandP.10).gifOnly use Secure Sockets Layer (SSL) for pages that require it.
Ff647706.checkbox(en-us,PandP.10).gifUse absolute URLs for navigation.
Ff647706.checkbox(en-us,PandP.10).gifConsider using SSL hardware to offload SSL processing.
Ff647706.checkbox(en-us,PandP.10).gifTune SSL timeout to avoid SSL session expiration.

Deployment Considerations

CheckDescription
Ff647706.checkbox(en-us,PandP.10).gifAvoid unnecessary process hops.
Ff647706.checkbox(en-us,PandP.10).gifUnderstand the performance implications of a remote middle tier.
Ff647706.checkbox(en-us,PandP.10).gifShort-circuit the HTTP pipeline.
Ff647706.checkbox(en-us,PandP.10).gifConfigure the memory limit.
Ff647706.checkbox(en-us,PandP.10).gifDisable tracing and debugging.
Ff647706.checkbox(en-us,PandP.10).gifEnsure content updates do not cause additional assemblies to be loaded.
Ff647706.checkbox(en-us,PandP.10).gifAvoid XCOPY under heavy load.
Ff647706.checkbox(en-us,PandP.10).gifConsider precompiling pages.
Ff647706.checkbox(en-us,PandP.10).gifConsider Web garden configuration.
Ff647706.checkbox(en-us,PandP.10).gifConsider using HTTP compression.
Ff647706.checkbox(en-us,PandP.10).gifConsider using perimeter caching.