Web Application Performance Design Inspection Questions - Resource Management

From Guidance Share

Jump to: navigation, search

- J.D. Meier, Srinath Vasireddy, Ashish Babbar, Rico Mariani, and Alex Mackman


Resource Management Issues



Not pooling costly resources

Can result in creating many instances of the resources along with its connection overhead. Increase in overhead cost affects the response time of the application.

Holding onto shared resources

Not releasing (or delaying the release of) shared resources, such as connections, leads to resource drain on the server and limits scalability.

Accessing or updating large amounts of data

Retrieving large amounts of data from the resource increases the time taken to service the request, as well as network latency. This should be avoided, especially on low bandwidth access, because it affects response time. Increase in time spent on the server also affects response time as concurrent users increase.

Not cleaning up properly

Leads to resource shortages and increased memory consumption; both of these affect scalability.

Failing to consider how to throttle resources

Large numbers of clients can cause resource starvation and overload the server.

Common resource management issues include failing to release and pool resources in a timely manner and failing to use caching, which leads to excessive resource access. To assess the efficiency of your application's resource management, review the following questions:

  • Does your design accommodate pooling?
  • Do you acquire late and release early?

Does Your Design Accommodate Pooling?

Identify resources that incur lengthy initialization and make sure that you use pooling, where possible, to efficiently share them among multiple clients. Resources suitable for pooling include threads, network connections, I/O buffers, and objects.

As a general guideline, create and initialize pools at application startup. Make sure that your client code releases the pooled object as soon as it finishes with the resource. Consider the following:

Do you use Enterprise Services?

Consider object pooling for custom objects that are expensive to create. Object pooling lets you configure and optimize the maximum and minimum size of the object pool. For more information, see "Object Pooling" in Chapter 8, "Improving Enterprise Services Performance."

Do you treat threads as shared resources?

Use the .NET thread pool, where possible, instead of creating threads on a per - request basis. By default, the thread pool is self-tuning and you should change its defaults only if you have specific requirements. For more information about when and how to configure the thread pool, see Explained: ASP.NET Formula for Reducing Contention and ASP.NET 2.0 Performance Guidelines - Threading.

Do you use database connection pooling?

You should connect to the database by using a single trusted identity. Avoid impersonating the original caller and using that identity to access the database. By using a trusted subsystem approach instead of impersonation, it enables you to use connection pooling efficiently.

More Information

For more information about connection pooling, see ADO.NET 2.0 Performance Guidelines - Connections.

Do You Acquire Late and Release Early?

Minimize the duration that you hold onto a resource. When you work with a shared resource, the faster you release it, the faster it becomes available for other use rs. For example, you should acquire a lock on a resource just before you need to perform the actual operation, rather than holding onto it in the pre-processing stage. This helps reduce contention for the shared resources.

Personal tools