Hi Maciek,

On Nov 20, 2007 5:26 AM, Maciek Stachowiak <[EMAIL PROTECTED]> wrote:
>
> Hi Trustin, sorry for messing up your name last time...
>
> Ok, so assuming I use MINA 2.0 (probably the best option) I found some code
> you had posted previously...
>
>         SocketAcceptor acceptor = new NioSocketAcceptor();
>         acceptor.getFilterChain().addLast("executor", new ExecutorFilter(
>             new UnorderedThreadPoolExecutor( 0, 16, 30, TimeUnit.SECONDS,
> new IoEventQueueThrottle())));
>         acceptor.setHandler(new IoHandlerAdapter() {
>             @Override
>             public void messageReceived(IoSession session, Object message)
> throws Exception {
>                 Thread.sleep(1000);
>             }
>         });
>         acceptor.setLocalAddress(new InetSocketAddress(1234));
>         acceptor.bind();
>
>
> So I just want to make sure I'm reading this right, your adding the
> UnorderedThreadPoolExecutor to the NioSocketAcceptor which will create new
> threads as needed to a maximum of 16. Your adding a handler to the Acceptor
> which I assume could be any class that extends IoHandlerAdapter. So if
> there's alot of traffic, instances of the IoHandlerAdapter will be called
> into service as needed? Is there any rule of thumb for corePoolSize and
> maximumPoolSize? I'm a little shady regarding the keepAliveTime and
> IoEventQueueThrottle() still too...

Just one instance of IoHandler will handle all incoming connections
into the acceptor.  However, this doesn't relate to scalability at all
because your IoHandler implementation will be invoked with IoSession
instance so it's a kind of stateless.

Regarding the number of poolSize properties, You will have to
experiment by yourself because it's different between environments.
I'd suggest 0 as corePoolSize and more than 10 seconds as
keepAliveTime.

IoEventQueueThrottle is optional.  It is used to limit the number of
queued events to prevent OutOfMemoryError.  You will have to specify a
proper threshold as its constructor parameter instead of the default
value.  Actually I don't even remember what default value was for now.
:D

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Reply via email to