开发者

Pooling concept in java or EJB?

开发者 https://www.devze.com 2023-03-17 06:57 出处:网络
We have pooling concept in stateless EJB.What is the advantage of using po开发者_运维百科oling? My understanding is that it will save time in object creation.

We have pooling concept in stateless EJB. What is the advantage of using po开发者_运维百科oling? My understanding is that it will save time in object creation. Is this right? If yes, is there a significant difference in performance in creating the object or getting it from the existing pool? Does the pooling serve any other purpose than this?


Pooling can be usefull for sharing limited resources (e.g. database connections) and re-using objects that are expensive to create and/or destroy. When combined with an EJB, it can limit the load on the overall system which is very usefull when you run a server. According to the accepted answer in a similar question, it also helps with thread-safety.

An EJB can be expensive to create (or setup) when various resources and other EJB's are injected (with annotations), which, in my experience, is a common case. However, it appears that for example JBoss repeats this process even for pooled EJBs (see the answer from Tom Anderson in the similar question).

If a common EJB in a pool is often injected in other EJBs, the other EJBs will have to wait for a common EJB to become available when the system is really busy. The common EJB in a pool is then acting as a shared limited resource. The drawback is that you can get time-out exceptions (after for example 50 seconds) at unexpected places when a common EJB is not available (sometimes caused by a hickup in the infrastructure).

I have some experience with a JBoss server that has that pool mechanism for stateless EJBs in place. Within that JBoss server there is a common EJB that uses a database connection frequently. If a huge amount of work enters the system all at once, the load will be high but limited by the pooling mechanism. If the pooling mechanism limits the maximum load too much, the maximum load can be increased by increasing the maximum pool size.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号