I am testing multicast of Aeron vs raw TCP server - client.
Aeron model setup:
- MD processes on each node
- Starting 1 Publication and 1 Subscriber
Raw Tcp server client:
- Server: 1 Thread to push 1 million integer messages
- Client: 1 Thread consuming
Result: Aeron UDP: Taking around 17 seconds Raw TCP: Taking around 8 seconds
As I understand UDP multicast way should be faster than TCP, am I missing anything or misunderstood ? What I should check or fined-tune to make Aeron faster
TCP Server
serverSocket = new ServerSocket(port);
while(true) {
Socket clientSocket = serverSocket.accept();
Thread t = new Thread(){
@Override
public void run() {
try{
System.out.println("Starting new thread serving client");
out = new DataOutputStream(clientSocket.getOutputStream());
in = new DataInputStream(new BufferedInputStream(clientSocket.getInputStream()));
for (int i = 0; i < 1_000_000; i++) {
System.out.println("Server sending..." + i + "..!");
out.writeInt(i);
}
} catch (IOException e){
//
}
}
};
t.start();
}
TCP client
System.out.println("I'm client!");
TcpClient client = new TcpClient();
String serverHost = System.getProperty("host");
try {
client.startConnection(serverHost, 6666);
DataInputStream in = client.in;
long st = System.currentTimeMillis();
int counter = 1_000_000;
while(counter > 0) {
int v = in.readInt();
// System.out.println("v: " + v);
counter--;
}
long pt = System.currentTimeMillis() - st;
System.out.println("Process time of TCP raw: " + pt);
} finally {
client.stopConnection();
}