Can you add this line in your server :
((SocketSessionConfig) acceptor.getSessionConfig()).setTcpNoDelay(false)
and see if it makes any difference ?
Zvika Gart wrote:
Sorry, but Nagle doesn't have anything to do with this...
Nagle is relevant at the *client side* when sending small buffers over the
network.
My client is a simple C# program (not MINA, so SocketConnector is
irrelevant) that sends large buffers (100KB) at each call to Socket.Send()
If Nagle was to blame then I would see the same bandwidth from both server
implementations. This is not the case.
On Tue, Nov 24, 2009 at 8:41 PM, Emmanuel Lecharny <[email protected]>wrote:
Damn Nagle ! ( http://en.wikipedia.org/wiki/Nagle_algorithm )
Check the FAQ : http://mina.apache.org/faq.html (
Why does SocketConnector send several messages as one message?)
Zvika Gart wrote:
Hello,
Please help, as this is too strange to be true...
I'm comparing two implementations of the most basic socket server - it
listens for a client, and after accepting it just starts reading data from
it.
The first implementation using Java's plain old ServerSocket:
ServerSocket srv = new ServerSocket(80);
Socket s = srv.accept();
InputStream i = s.getInputStream();
byte[] buf = new byte[1024 * 8];
while (true) {
i.read(buf);
}
The Second implementation using MINA 1.1.7 (which so simple that I can
paste
it here):
First the Main class:
package test;
import java.net.InetSocketAddress;
import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.IoAcceptor;
import org.apache.mina.common.SimpleByteBufferAllocator;
import org.apache.mina.transport.socket.nio.SocketAcceptor;
public class Main {
public static void main(String[] args) throws Exception {
// The following two lines don't help
ByteBuffer.setUseDirectBuffers(false);
ByteBuffer.setAllocator(new SimpleByteBufferAllocator());
IoAcceptor acceptor = new SocketAcceptor();
acceptor.bind(new InetSocketAddress(80), new MyHandler());
}
}
And the IoHandler:
package test;
import org.apache.mina.common.IoHandlerAdapter;
public class MyHandler extends IoHandlerAdapter {
}
I wrote a simple client that connects to the server and pumps continuous
data.
Both client and server run on Amazon's EC2 on Debian Linux instances
(64-bit, Java 1.6). Client is in Europe and server in USA.
*The results:*
Simple Java implementation - 5 Mbps
MINA implementation - 750 Kbps
Tried removing the setUseDirectBuffers lines; tried a simpler threading
model by running the IoHandler on the IoProcessor threads... nothing helps
-
MINA is capped at 750 Kbps.
What is going on here?!
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org