Susan-mhy (11) [Avatar] Offline
#1
As my understanding, Servlet has one instance and thread pool for different users.
Does stateless bean has instance pool? Why not just has one instance and thread pool for different users?
Susan-mhy (11) [Avatar] Offline
#2
Re: Difference between servlet and stateless bean
And also MDB. Why should we keep multiple instances in pool? Seems one instance can serve multiple users. we can just use thread pool instead of instance pool.
reza_rahman (456) [Avatar] Offline
#3
Re: Difference between servlet and stateless bean
Susan,

Please look at some previous threads since this question has been answered already.

The reason you need an instance pool and not simply a thread pool is scalability. In most production systems the performance level would be unacceptable if a large number of concurrent users are waiting on a single component instance - it would quickly become a bottle-neck. Instance pooling saves GC resources and implements bandwidth throttling while still keeping the components thread-safe and scalable.

Cheers,
Reza
Susan-mhy (11) [Avatar] Offline
#4
Re: Difference between servlet and stateless bean
Thanks, Reza.
I will go through the old threads to see whether I have new question.
Actually someone told me there is a instance pool for stateful session bean. So that when a new request arrives, it saves time.
I will see the old threads to see whether this is also discussed.
reza_rahman (456) [Avatar] Offline
#5
Re: Difference between servlet and stateless bean
Susan,

Stateful session beans are generally not pooled because the instance state cannot be guarateed to be cleared between sessions. Threads are usually pooled across the server no matter if they are used for HTTP requests, EJB sessions or anything else.

Cheers,
Reza
Susan-mhy (11) [Avatar] Offline
#6
Re: Difference between servlet and stateless bean
The stateful instance's pool , the instances in it are just new stateful instances, when a new session bigins, no need to build a new instance, just use one already exists. I was also told that it is also used during passvate and activate. I was told so, but I am not sure.
And for stateless bean pool, one instance serves only one thread or multi-thread at the same time?
Thanks
reza_rahman (456) [Avatar] Offline
#7
Re: Difference between servlet and stateless bean
Susan,

Stateful beans support passivation, not pooling. Stateless session bean pooled instances are assigned to one thread at a time. Multiple threads are assigned multiple instances from the pool if needed.

Hope it helps,
Reza
Susan-mhy (11) [Avatar] Offline
#8
Re: Difference between servlet and stateless bean
Hi, reza,
I found the previous thread.
Thank you very much for your reply.
Your book is simple and useful.

Susan