dcsimg
Why not use just a single Stateless Session Bean?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Dominic_Cioccarelli
Posted On:   Thursday, February 14, 2002 03:08 PM

Given that a stateless session bean can't maintain conversational state, why bother creating multiple instances? It would seem to be more efficient just to use a single instance to serve all clients. From what I can see the reasons are twofold: (1) With EJBs (unlike RMI) multiple clients can't invoke methods on a single object at the same time. Requests are serialized. Therefore instance pools are used to increase performance. (2) EJBs can be instantiated on multiple machines thus you can never mandate a singleton. Personally I feel that not allowing concurrent access to stateless session beans is an unnecessary constraint. Sure it means that bean developers don't need to deal with concurr   More>>

Given that a stateless session bean can't maintain conversational state, why bother creating multiple instances? It would seem to be more efficient just to use a single instance to serve all clients.



From what I can see the reasons are twofold:


(1) With EJBs (unlike RMI) multiple clients can't invoke methods on a single object at the same time. Requests are serialized. Therefore instance pools are used to increase performance.

(2) EJBs can be instantiated on multiple machines thus you can never mandate a singleton.



Personally I feel that not allowing concurrent access to stateless session beans is an unnecessary constraint. Sure it means that bean developers don't need to deal with concurrency issues, but it also decreases performance leading to the use of instance pools and the associated object instantiation overhead.

   <<Less

Re: Why not use just a single Stateless Session Bean?

Posted By:   mike_k  
Posted On:   Friday, February 15, 2002 02:04 AM

Could you tell me what you think if 2 clients
access this method below at the same time.


int test_method(int a){
while( a-- > 0 ){
a+=a;
}
return a;
}




Don't forget that this method is NOT synchronized.

U got, huh ?

You should learn more Basics of JAVA.
Too early for you to learn EJB.
U would make serious BUGs...
or Did I say too much ? sorry~ :)
About | Sitemap | Contact