7.5. Tuning the Stateless-Session Bean Pool

JOnAS handles a pool for each stateless Session Bean. The pool can be configured in the JOnAS-specific deployment descriptor with the following tags:

min-pool-size

This optional integer value represents the minimum instances that will be created in the pool when the bean is loaded. This will improve bean instance creation time, at least for the first beans. The default value is 0.

max-cache-size

This optional integer value represents the maximum of instances in memory. This value keeps JOnAS scalable.

The policy is that, at bean creation time, an instance is taken from the pool of free instances. If the pool is empty, a new instance is always created. When the instance must be released (at the end of a business method), it is pushed into the pool, except if the current number of instances created exceeds the max-cache-size, in which case this instance is dropped. The default value is no limit.

<jonas-ejb-jar>
  <jonas-session>
    <ejb-name>SessSLR</ejb-name>
    <jndi-name>EJB/SessHome</jndi-name>
    <max-cache-size>20</max-cache-size>
    <min-pool-size>10</min-pool-size>
  </jonas-session>
</jonas-ejb-jar>

Example 7-1. Stateless-Session Bean Pool Example