Ashish-24 wrote:
>
> Can you post the missing code pieces (MessageHandler, Message) and
> your client. Would like to run it myself.
>
> Thanks, Ashish! The message is a generated RPC message that requires more
> runtime support. However, it doesn't really matter much. The handler is a
> dummy one that doesn't do much other than deserializing/serializing
> messages(that is, sort of like an echo server). I created a dummy one
> using Java object serialization below. By the way, do I have to use MINA's
> client code? My client uses plain DatagramSocket.
>
> class Message implements Serializable{
> int foo = 10;
> String bar = "a test string";
> Double foobar = 1.23432;
> String[] testArray = {"a", "abc", "adfafd", "adfadf", "afadwerwe",
> "adfafd", "cefwerwer"};
> }
>
> public class MessageHandler{
> ObjectInputStream in = null;
> try {
> in = new ObjectInputStream(new ByteArrayInputStream(data));
>
> return (Message)in.readObject();
>
> } catch (ClassNotFoundException e) {
> throw new RuntimeException(e);
> } catch (IOException e) {
> throw new RuntimeException(e);
> }finally{
> try{
> if(in != null){
> in.close();
> }
> }catch(IOException e){
>
> }
> }
> }
>
> On Tue, Oct 28, 2008 at 11:32 AM, Yong Yuan <[EMAIL PROTECTED]> wrote:
>> On Mon, Oct 27, 2008 at 10:42 PM, Ashish <[EMAIL PROTECTED]> wrote:
>>
>>> What's the value of BUFFER_SIZE? My experience with MINA (2.0)has been
>>> great, had a UDP Server
>>
>>
>> I tried various values ranging from the default to 8MB. None helped much,
>> though.
>>
>>
>>>
>>> implementation with 1000+ packets/sec. Since I couldn't afford to
>>> loose packets, had set the Receive Buffer
>>> to a high value. Though it ate up a bit of memory, but one can live
>>> with a few Megs extra usage on 8 GB Server.
>>>
>>> BTW, how did you interpreted that your MINA implementation was dropping
>>> packets?
>>
>>
>> The client timed out even when the timeout value was 16 seconds and the
>> server spent less than a second to handle each message. I also ran
>> netstat,
>> and saw packet losses. There could be other possibilities though, but I
>> can't think of any for the moment.
>>
>>
>>
>>>
>>>
>>> thanks
>>>
>>> On Tue, Oct 28, 2008 at 11:05 AM, Yong Yuan <[EMAIL PROTECTED]> 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();
>>> > }
>>> > }
>>> >
>>>
>>>
>>>
>>> --
>>> thanks
>>> ashish
>>>
>>> Blog: http://www.ashishpaliwal.com/blog
>>>
>>> My Photo Galleries: http://www.pbase.com/ashishpaliwal
>>>
>>
>
>
>
> --
> thanks
> ashish
>
> Blog: http://www.ashishpaliwal.com/blog
>
> My Photo Galleries: http://www.pbase.com/ashishpaliwal
>
>
--
View this message in context:
http://www.nabble.com/Packet-loss-when-using-MINA-UDP-tp20201649p20212741.html
Sent from the Apache MINA User Forum mailing list archive at Nabble.com.