mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Asher, Angela" <aas...@iskoot.com>
Subject RE: mina version 2.0.4, thread model
Date Sun, 12 Feb 2012 15:31:22 GMT
Thank you for the quick response.
That helped.
I have a following question, regarding your last answer. if one session is very long to process,
is it possible to configure the thread pool to create a new thread on demand? That means that
if a single thread can handle all the sockets, than only one thread will be created, but if
the thread is too busy, it will create another thread ( or as much as needed ).

Thanks,
Angela

-----Original Message-----
From: Emmanuel Lécharny [mailto:elecharny@gmail.com] 
Sent: Sunday, February 12, 2012 5:24 PM
To: dev@mina.apache.org
Subject: Re: mina version 2.0.4, thread model

Le 2/12/12 12:58 PM, Asher, Angela a écrit :
> Hi,
>
> I am new to Mina, and I have a question regarding the thread model.
> I am now using the Executor.newCachedThreadPool() Which as I 
> understand manages the I/O processor threads.
> My question is, does the amount of live I/O processor threads match the amount of open
sockets?
No. The ExecutorFilter is used to create a separate pool of threads when processing a message
that has been already processed by one IoProcessor. 
You may have many IoProcessor already, and each session will be associated with one and only
one IoProcessor. As one IoProcessor thus can handle many Sessions, it may be necessary to
use another thread pool behind the IoProcessor to guarantee that a slow session will not block
teh other sessions handled by the same IoProcessor.
> For example: if I have two open sockets, each one has it's own I/O 
> processor thread,
No. Two sockets may perfectly be handled by one single IoProcessor. But they can also be managed
by two, it depends on how and when they have been opened. Currently the used algorightm to
spread the newly crated sessions is a round robin mechanism.
> or,
> Can a single thread handle the messageReceived events for example for both sockets, if
the thread is not busy when the events arriving.
Yes. And it's likely to be the case. That also means that if one session is very long to process,
then all the other sessions will be pending, waiting for this session to terminate its execution.

Hope it helps.


--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Mime
View raw message