It would be quite nice to be able to do something equivalent to sendto() with
a DatagramAcceptor or a DatagramConnector.

I've written a UDP application based on Mina that sends precisely 1 packet
to 1 million end points, and waits for 1 packet from 1 million end points. 
Each 2 packet exchange is 1 Mina IoSession, and I continuously reuse the
same 1000 - 5000 prebound IoSession objects, that is, I keep 1000 - 5000 of
these exchanges in flight at a time.

Profiling the application showed me that it spends 60% of its CPU time in
the newSession() call.  I need to create a session per remote end point, so
that's 1 million calls to DatagramAcceptor.newSession(), and it hurts.

I used to do this with DatagramConnector.connect(), but this was 2 times
slower than the current implementation using DatagramAcceptor.

It would be nice to be able to send the packet and not bind with the remote
destination first, and would probably double my performance.  And
performance is very, very important to me in this application.



Trustin Lee wrote:
> 
> 
>> In java.nio I have the choice if I want to send a datagram using a
>> connection, or if I'm using the DatagramChannel.recieve/send methods.
>> Do I have this choice in Mina as well, since it is built on top of
>> java.nio...
> 
> 
> For now, you have to bind first:
> 
> InetSocketAddress address = new InetSocketAddress( 8080 );
> IoAcceptor acceptor = new DatagramAcceptor();
> acceptor.bind( address, handler );
> IoSession session = acceptor.newSession( address, new InetSocketAddress( "
> remote.host.com", 8080 ) );
> session.write( ... );
> 
> If you don't want to bind, there's no such way yet.  Please let us know if
> this becomes a problem.  This means we need to modify our API to fill the
> abstraction hole.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Re%3A--mina--Sending-datagrams-without-connection-tp7520296s16868p15385247.html
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.

Reply via email to