Forums Register Login

Why pool stateless session beans when you can get by with one instance?

+Pie Number of slices to send: Send
Since stateless session beans doesn't have states, it seems that we could get by with just one instance per bean type to serve its calls, similar to the servlet model where multiple requests are handled by a single multithreaded servlet - ignoring the possibility of SingleThreadedModel for now.

I understand that each stateless bean call needs to be remote so each "client" can connect to a different remote objects (EJBObject - keeping track of the socket connections (via the rmi stubs/skels)..etc) on the server side. But then each of these ejbobjects can simply delegate to a single bean instance, afterall, it's stateless. So what's the benefits of having a pool of stateless bean instances as described in the EJB spec?

p.s. I actually had this question in my mind 5 years ago but never seemed to find anyone or materials that could answer this satisfactorily.
+Pie Number of slices to send: Send
Simply put to handle more throughput of clients. Just like why you have a Connection Pool. So that users don't have to wait. In Tuning applications, one of the biggest strategies for performance tuning is tuning wait points. When a client waits that slows things down, so make pools of stuff so that clients don't have to wait.

Mark
+Pie Number of slices to send: Send
However, if the bean is stateless, we can simply multithread through one instance, again, similar to servlet. e.g., 100 stateless bean calls translates to 100 threads through one bean instance (you might still need 100 remote objects - the EJBObject) instead of 100 identical bean instances that doesn't seem to have benefits.

Db connection pool is different - each connection is stateful, typically for the duration of a transaction.
+Pie Number of slices to send: Send
Look ma! I'm selling my stuff!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 705 times.
Similar Threads
stateless vs stateful session beans
Why have more than one stateless session bean?
Best practice for stateless session bean in a servlet
The benefit of pooled stateless session beans vs singleton use?
Stateless session beans are pooled.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 01:52:53.