Fellow Java Linux users:
I have a simple client/sever benchmark (code below) designed to see how
many simultanious open sockets I can sustain. The answer seems to be
about 250. This is really sad because the crufty HP-UX JDK 1.1.3
managed to make it to 1200. The exception is weird, too. Linux throws:
java.net.SocketException: Invalid argument
HP-UX throws:
java.net.SocketException: Too many open files
...which makes a lot more sense.
I am running:
JDK 1.1.6v1
Redhat 5.0
Pentium II-266 128M
10 Based T
Shouldn't I be able to do better than 250 sockets? Is there a tunable
parameter I'm missing? I need to reach 2500... or I have to use a
different OS/Language combo!
-----------------8<--- To Reproduce --------------------------
I run the following pairs (see code below):
java MonsterServer 2500 15
java SocketMonster 2500 localhost
-----------------8<--- MonsterServer.java --------------------------
import java.net.*;
import java.util.*;
public class MonsterServer {
public static void main(String[] argv) {
int i = 0;
try {
int numsocks = Integer.parseInt(argv[0]);
int maxq = Integer.parseInt(argv[1]);
System.out.println("Maximum set to " + numsocks + " sockets: "
+ new Date());
Socket[] s = new Socket[numsocks];
ServerSocket ss = new ServerSocket(4321, maxq);
while(i < numsocks) {
s[i++] = ss.accept();
}
System.out.println("Socket limit reached");
} catch(Exception e) {
e.printStackTrace();
System.out.println("We opened " + i + " sockets.");
}
}
}
-----------------8<--- SocketMonster.java --------------------------
import java.net.*;
import java.util.*;
public class SocketMonster {
public static void main(String[] argv) {
int numsocks = Integer.parseInt(argv[0]);
System.out.println("Opening " + numsocks + " sockets: "
+ new Date());
Socket[] s = new Socket[numsocks];
int i = 0;
try {
System.out.println("Starting the opens: " + new Date());
for(i = 0; i < numsocks; s[i++] = new Socket(argv[1], 4321));
for(i = 0; i < numsocks; s[i++].close());
} catch(Exception e) {
e.printStackTrace();
System.out.println("We made it to socket " + i);
}
}
}
-----------------8<--- End Code --------------------------