dev@directory.apache.org
[Top] [All Lists]

Re: [MINA] IoSession and method write (performance)

Subject: Re: [MINA] IoSession and method write performance
From: Niklas Therning
Date: Mon, 02 Jan 2006 19:48:11 +0100
Alessandro Torrisi wrote:
> ...
> Now the question is, according to you it's better to write on the IoSession 
> one single time with a big message or fragment the big message in more
> writes ?

If you have to write 1000 lines you should in most cases not call
session.write() 1000 times. For every call to session.write() a
messageSent() event will be triggered which will consume threads from
your thread pool and CPU. So it's probably a good thing to keep the
number of calls to session.write() down by writing the lines in larger
chunks.

Just don't make the chunks too large (typically several MB) or you could
risk running out of memory (depending on the characteristics of your
application).

/Niklas

<Prev in Thread] Current Thread [Next in Thread>