"1.0" encoding="UTF-8" xml version= <glassfish-ejb-jar> <enterprise-beans> <ejb> <ejb-name>PooledStatelessBean</ejb-name> <bean-pool> <max-pool-size>1</max-pool-size> <max-wait-time-in-millis>0</max-wait-time-in-millis> <steady-pool-size>1</steady-pool-size> </bean-pool> </ejb> <ejb> <ejb-name>PooledMDB</ejb-name> <bean-pool> <max-pool-size>1</max-pool-size> <resize-quantity>1</resize-quantity> </bean-pool> </ejb> </enterprise-beans> </glassfish-ejb-jar>
Controlling Stateless EJB Concurrent Instances
Since Payara Server 126.96.36.199
In prior releases, it was not possible to control the maximum number of concurrent Stateless EJB instances in Payara Server. It was, however, possible to control the number of pooled Stateless EJB instances, as well as concurrent MDB instances.
|These features were available in Oracle GlassFish Server 3.1 and earlier but not in the GlassFish Open Source editions (3.1.2.x and 4.x).|
It is possible to limit concurrent Stateless EJB instances that are dispatched, allowing fine-grained control of resources, limiting surface area for DDOS attacks and making applications run more smoothly and efficiently.
The key difference is that previously it was not possible to limit the number of concurrent threads dispatched for the same Stateless EJB, the only limit was the number of pooled beans. When the pool ran out, new EJB instances were created, with no upper bound. In the current release, this upper bound can be established so the maximum number of threads is not exceeded beyond this value.
Deployment Descriptor Configuration
These limits can be controlled on a per-EJB basis, using
bean-pool elements in the
glassfish-ejb-jar.xml deployment descriptor file with the use of these specific tags and elements only available for Payara Server:
This element controls the maximum concurrent instances that are dispatched for this EJB (number of threads). The default is configured in the domain; this has not changed from previous versions.
This element controls what to do when the number of requests exceeds the amount of beans available in the pool. Possible values of this element include:
This element controls the minimum number of beans in the bean pool. This will increase performance at the expense of memory footprint.
Additionally, a new system property
can be set to change the default global value of
for all Stateless EJB bean pools.
|Unless overridden in the deployment descriptor file, this will become the new default value and can be used to cap the upper bound of all concurrent invocations of any Stateless EJB pools.|
The following is a sample
glassfish-ejb-jar.xml deployment descriptor that configures 2 EJBs with the settings mentioned beforehand.