Hi. I have a question about concurrent access of many clients. Suppose I have a stateless session bean, which is pooled, and the pool has at most 10 instances. Does this mean 10 clients can be served simultaneously (1 for each bean, the 11th client waits) or can many many more client be served (because each of the pooled beans can be accessed by many threads of control)? The same would relate to MDBs. With stateful session beans, if I have a million clients connected, and the memory and hardware would allow this, would I have a million ejb instances? What if the server runs out of memory? Does it throw an exception then? Thanks.
1. The number of concurrent stateless session beans are limited by the upper bound for the pool. If you don't think you need bandwidth control, you can set the pool size to increase indefinitely (not all app servers support this since it is really not advisable from an application SLA standpoint). 2. Once memory is low enough, most application servers will start serializing stateful session beans to the disk. This works as long as the high number of stateful clients are not "truly" concurrent. This is one of the reasons I worry about things like Seam that encourage the stateful model more than is necessary.
Independent Consultant — Author, EJB 3 in Action — Expert Group Member, Java EE 6 and EJB 3.1