You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Alessandro Torrisi <al...@eurone.it> on 2006/01/02 18:09:55 UTC
[MINA] IoSession and method write (performance)
Hi ! I'm developing a little Hub Server for Direct Connect Protocol (P2P), and
I'm experiencing some big performance problems.
When I posted the first messages Niklas answered me that it could be the
database which could block threads, so he told me that I had to use some O/R
product like Hibernate.
So I used Hibernate, performance with its cache and connection pooling
mechanisms effectively are better, but no sufficient to be considered a good
product.
I'm searching for performance tips...So I have a question...but before a
little example about the communication between client and server (a login
handshake)
clients connect...server sends a key and the hubname
S: $Lock fdsjfsiodfjaiosdjfsaomfoos Pk=somekey|
S: $HubName myhubname.mydomain.com|
...
clients asks the server to validate the nick, sends his info and asks for the
userlist:
C: $Validate MyNick|
C: $MyINFO $ALL MyNick iinfo....|
C: $GetNickList|
server answers with all the MyINFO of the connected users:
S: $MyINFO $ALL user1 info...|
S: $MyINFO $ALL user2 info...|
S: $MyINFO $ALL user3 info...|
S: $MyINFO $ALL user4 info...|
S: $MyINFO $ALL user5 info...|
...
S: $MyINFO $ALL user1000 info...|
...
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 ?
Then...now I tryied to use a threadPool of 10 elements in my overriden class
of ServiceRegistry...what about this ? How can I tune this parameter ? What
are the refs ?
Best regards,
Alessandro Torrisi
Re: [MINA] IoSession and method write (performance)
Posted by Niklas Therning <ni...@trillian.se>.
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