On 4/12/11 12:31 PM, Mavlarn Tuohuti wrote:
There are 2 places where Mina uses multi-thread, IoProcessor(to accept new
connection) and IoHandler(to handle the event).
Nope. Once you have created IoProcessor threads ( default to nb CPU +1),
you don't have any more thread created.
It's up to the user to add an Executor in the chain, or to have some
executor in the application.
By default, Mina will use (cpu count + 1) threads for IoProcessor. you can
set the count as below:
NioSocketAcceptor acceptor = new NioSocketAcceptor(10);
But, in the normal, the process of creating new connection is quick, so no
need to set this count a big number. But you can try.
As I said, it's not only about creating new connection : once your
message is pushed to an IoProcessor, the thread will process the message
until it has done its job, and it includes the IoHandler processing. If
your application processing is heavy, with some contention (DB access),
then adding an executor in the filter chain may be necessary.
As I know, IoProcessor and IoHandler are working in separate threads. S
Wrong. Unless you have added an executor in the chain.
o the
blocking in messageReceived() should not affect new connection.
I think you can check the logic of broadcasting. Maybe it occupied the
IoSession of client.
What I would check is how the outgoing data are processed in the codec.
It would be an excellent idea to push the data in small chunks, instead
of writing a 100kb block of data, for many reasons. One of them is that
your 100kb will stay in memory until all of it has been sent, and this
is definitively not good, and another reason is that it might take time
to be ready to send the first byte if you have an heavy processing
before it hits the socket.
Now, if you have some time out on the client side, it's very likely that
you have some contention on your server, and it would be wise to run
some performance tool to know excalty what's going on.
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com