Hi Csaba,
On 3/13/07, Csaba Endre Simon <[EMAIL PROTECTED]> wrote:
Hi all,
I am quite new to MINA, so please be patient with me :-) Reading the
mailing list, I saw that MINA can handle thousand of messages/sec.
However my experience shows something else. I am developing a database
proxy and with this proxy the throughput is 20X slower (30/sec vs
600/sec) This means that I am doing something really bad. Please help
me answering this questions to understand what I am doing wrong:
1. the main application code:
ByteBuffer.setUseDirectBuffers(false);
ByteBuffer.setAllocator(new SimpleByteBufferAllocator());
IoAcceptor acceptor = new SocketAcceptor();
acceptor.getDefaultConfig().setThreadModel(ThreadModel.MANUAL);
SocketAcceptorConfig cfg = new SocketAcceptorConfig();
cfg.setReuseAddress(true);
cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(new
ABCProtocolFactory()));
acceptor.bind(new InetSocketAddress(SERVER_PORT), new ABCSessionHandler(),
cfg);
Does it looks good the initialization of the application?
If your business logic is to perform database operations, then you'd better
add an ExecutorFilter. You might not be able to get expected performance if
your database is bottleneck.
2. In ABCSessionHandler (extends IoHandlerAdapter) can I write
multiple times to the session? Does it have any performance issue if I
do it?
No usually. You might want to turn off Nagle's algorithm. Please try to
enable SO_TCPNODELAY as a last resort. Most server applications doesn't
need this option though.
3. In the ABCSessionHandler where the application logic is I am doing
JDBC calls. Do I need to move somewhere else the JDBC calls? If yes,
on what layer?
I already answered this question in the question #1.
4. The proxy is sending out very short messages. From my C++
experience I known that performance can boost (5-10x times) if the
sending of this messages is buffered. I want to trigger the sending of
the buffer (which will contains a lot of message) only when:
a. the buffer size is equal with MAX_BUFFER_SIZE or
b. when I flush() the buffer
How can I do this in MINA?
hmm.. it's an interesting feature. You could probably call
IoSession.suspendWrite(), write messages, and call IoSession.resumeWrite().
It won't create buffer, but it will delay the write timing. You will have
to implement it by yourself in your codec (or IoHandler if you are not using
a codec) if this doesn't work.
HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6