Thanks to all for helping out. The problem is gone. FWIW, here is what
happened: my test client timed out more and more frequently, and finally
stopped getting any response back. This looked more like a hardware or OS
problem than a framework fault. So, I restarted my laptop(A T61 with Windows
Vista Business), and the problem could no longer be reproduced.  MINA-based
RPC server then performed very well, handling thousands of messages per
seconds without any packet loss. 


Dannyy wrote:
> 
> Hi,
> My team is considering using MINA UDP to implement our RPC server. The
> problem is, we saw lots of packet loss when our prototype server tried to
> handle over 300 messages per second. I thought this was due to overflow of
> UDP's receiving buffer, but increasing the receiving buffer size didn't
> cure
> the problem. We also wrote a simple server that used plain DatagramSocket
> and dispatched incoming message to worker threads. This simple server
> worked
> well under thousands of messages per second even though it implemented
> exactly the same logic as the MINA version. We're using MINA 1.1.7.
> 
> My server can be simplified to the following code. The decoder, encoder,
> and
> IoHandler are very simple. They shouldn't take more than a few million
> seconds to run. May I know if I have missed anything, or if there is any
> tip
> or magic trick that I need to be aware of, in order to reduce packet
> losses?
> Thanks!
> 
> public static void main(String[] args) throws IOException {
> DatagramAcceptor acceptor = new
> DatagramAcceptor(Executors.newCachedThreadPool());
> 
> acceptor.getDefaultConfig().getSessionConfig().setReceiveBufferSize(BUFFER_SIZE);
> acceptor.getDefaultConfig().getSessionConfig().setReuseAddress(true);
>  acceptor.getDefaultConfig().setThreadModel(ThreadModel.MANUAL);
> acceptor.getFilterChain().addLast("threadPool", new
> ExecutorFilter(Executors.newCachedThreadPool()));
> acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new
> MyEncoder(), new MyDecoder()));
> 
> acceptor.bind(new InetSocketAddress(PORT), new MyHandler());
> System.out.println("UDP listening on "+PORT);
> }
> 
> private static class MyHandler extends IoHandlerAdapter {
> private MessageHandler handler = new MessageHandler();
> public void messageReceived(IoSession session, Object message) throws
> Exception {
> Message response = handler.execute((byte[])message);
> session.write(response);
> }
>  public void sessionClosed(IoSession session) throws Exception {
>  session.close();
>  }
>  }
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Packet-loss-when-using-MINA-UDP-tp20201649p20239155.html
Sent from the Apache MINA User Forum mailing list archive at Nabble.com.

Reply via email to