So, although the number of downloads of the sample program hasn’t been exactly great, I’m finally continuing the series. As I said in a previous article, I’d like to factor out the resizing behaviour - but before I do that, I want to integrate functionality that’ll let me evaluate the pool’s performance with regard to resizing, so I can assess the different resizing approaches reliably.
Fortunately performance monitoring is something that needs to be integrated into the pool implementation anyway and Windows has all the tools on board. So I only need to configure a few performance counters in Windows, make sure that these counters are updated with current numbers and the Windows performance monitoring frontend is available to the user to show it all in a nice graph. (I’m sure some of you have never heard of the performance monitor application - it’s available on the Administrative tools menu and it’s called, not surprisingly, Performance.)
Here’s the download for the current version, including these changes: ObjectPooling-2.zip
And these are the changes - at the end of the pool class:
In the ExtendPoolBy method:
In the ShrinkPoolBy method:
… and similar code for the other counter in the GetObject and ReleaseObject methods.
Can you provide a sample or partial sample code about how to use this code in ASP.NET environment.
Right now, most of the applications are web applications.
Thanks a lot.
Comment by Bruce — 20/4/2007 @ 10:08 pm - 1 year, 4 months ago
Did anybody actually use Object Pooling in their applications? What is the application performance impact after using Object Pooling?
Thanks.
Comment by Bruce — 23/4/2007 @ 10:04 pm - 1 year, 4 months ago
Hi Bruce - what do you mean "most of the applications are web applications"? What applications? In any case, my code is of course "just" a sample of how to implement object pooling, not an out of the box product for all scenarios.
As to the ASP.NET environment, I don’t exactly understand what you mean with your question. An object pool can be used in all situations where you want to have a number of objects available for shared (?) use. To use it, you’ll always have to set it up at some point, then make it available to callers. Maybe if you could give an example of the kind of objects that you’re trying to make available from your ASP.NET application, that might help me understand where you see the problem in that case.
Finally, I don’t know if anybody ever went and used my source code in their applications. I’m sure that object pooling as a technical approach is used in real world applications all the time. It’s a common technique that is used by many server systems. ADO.NET supports it, as one example, to allow you to get a database connection from a pool instead of creating it all the time. Web servers normally work that way, having a bunch of response threads running in a pool to avoid having to start one up when a request comes in.
The idea with object pooling is always that it is somehow a better idea to have an object readily available for a certain task, instead of having to create it and set it up when the task comes along. Now, creating an object is not really something that takes any significant time - it’s the setting up step that can take more time than we would like (opening network connections, database connections, reading metadata, whatever). In the end your application is supposed to work more performantly with object pooling in place. If it doesn’t, it’s not the fault of the object pooling approach, but rather of you using that approach in a situation where it’s not appropriate or useful.
Can you provide a sample or partial sample code about how to use this code in ASP.NET environment.
Right now, most of the applications are web applications.
Thanks a lot.
Comment by Bruce — 20/4/2007 @ 10:08 pm - 1 year, 4 months ago
Did anybody actually use Object Pooling in their applications? What is the application performance impact after using Object Pooling?
Thanks.
Comment by Bruce — 23/4/2007 @ 10:04 pm - 1 year, 4 months ago
Hi Bruce - what do you mean "most of the applications are web applications"? What applications? In any case, my code is of course "just" a sample of how to implement object pooling, not an out of the box product for all scenarios.
As to the ASP.NET environment, I don’t exactly understand what you mean with your question. An object pool can be used in all situations where you want to have a number of objects available for shared (?) use. To use it, you’ll always have to set it up at some point, then make it available to callers. Maybe if you could give an example of the kind of objects that you’re trying to make available from your ASP.NET application, that might help me understand where you see the problem in that case.
Finally, I don’t know if anybody ever went and used my source code in their applications. I’m sure that object pooling as a technical approach is used in real world applications all the time. It’s a common technique that is used by many server systems. ADO.NET supports it, as one example, to allow you to get a database connection from a pool instead of creating it all the time. Web servers normally work that way, having a bunch of response threads running in a pool to avoid having to start one up when a request comes in.
The idea with object pooling is always that it is somehow a better idea to have an object readily available for a certain task, instead of having to create it and set it up when the task comes along. Now, creating an object is not really something that takes any significant time - it’s the setting up step that can take more time than we would like (opening network connections, database connections, reading metadata, whatever). In the end your application is supposed to work more performantly with object pooling in place. If it doesn’t, it’s not the fault of the object pooling approach, but rather of you using that approach in a situation where it’s not appropriate or useful.
Comment by Oliver Sturm — 24/4/2007 @ 8:49 am - 1 year, 4 months ago