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?
2. In ABCSessionHandler (extends IoHandlerAdapter) can I write
multiple times to the session? Does it have any performance issue if I
do it?
public void messageReceived(IoSession session, Object message) throws
Exception {
Message1 m1 = new Message1();
session.write(m1);
...
Message2 m2 = new Message2();
session.write(m2);
...
}
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?
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?
Thanks,
Csaba