ComponentOne WebData for ASP.NET:Using WebDataObjects for ASP.NET Components > Object Pooling

Object Pooling

Another optimization technique used by C1WebDataObjects is object pooling. Object pooling is automatic, you don't need to write code or set properties to benefit from it. Thereare, however, a few properties that you might want to set to fine-tune object pooling.

Object pooling eliminates the need for C1WebDataObjects to create a new internal object each time to service a new request. Creating an internal object (called worker object) has a performance cost, although not particularly high  This performance cost is usually a small fraction of a second, but is perceptible nevertheless.

C1WebDataObjects maintains an internal pool of worker objects, which once created is never destroyed until the application process is shut down. The number of worker objects in the pool is limited by the PoolSize property. The first worker object is created when the first user makes a request for data. Then new worker objects are created and added to the pool on a need-to-serve basis. When a new request arrives, C1WebDataObjects first looks for a free worker object in the pool to service the request. If all worker objects are busy and the PoolSize limit has not yet been reached, a new worker object is created and added to the pool. If the pool is full, reached its maximum size, and all worker objects are busy, then the new request will wait until one of the busy worker objects finishes its job and becomes free to service the new request. This waiting time is limited by the PoolTimeout property. After the timeout expires, C1WebDataObjects throws an exception saying that it is unable to service the request. By default, this timeout is 0, which means that no timeout limit is imposed, the request will wait indefinitely until one of the worker processes becomes free, and the exception is never thrown. Setting non-zero PoolTimeout can make sense for cases where it is possible for a request (through user code) to hang indefinitely and you don't want this to affect other requests by making them wait indefinitely while all pooled worker processes are hanging (a rather hypothetical situation, but theoretically possible).

Object pooling can be disabled by setting PoolSize = 0. Then a new worker object is created for each new request and destroyed when it finishes serving the request.


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.