| ★ wanayoo — archive 1999 http://www.volano.com/linuxnotes.html | Nouvelle recherche | Portail wanayoo |
|
|
|
· Home |
Note that the information on this page has been superseded by our new Linux Support page. The information on this page is provided for reference in rebuilding the Linux kernel and thread library, and for installing the TowerJ version of VolanoChat. LinuxLinux 2.2 kernel file descriptors and tasksWhen running on the Linux 2.2 kernel, each process is limited by default to 1,024 file descriptors. Since the VolanoChat server requires one file descriptor for each person chatting through a VolanoChat applet, you are limited by default to a maximum of 1,024 simultaneous users when using the Linux 2.2 kernel. Some Java virtual machines, such as the IBM Developer Kit for Linux, Java Technology Edition, use native threads on Linux which require one task for each Java thread. Since VolanoChat requires two Java threads for each connection, you may need to increase the maximum number of tasks per user for such virtual machines. The default maximum number of tasks in a Linux 2.2 system is 512, with a maximum of 256 tasks per user. So by default, a VolanoChat server running under IBM JDK 1.1.6 for Linux can support a maximum of 128 people chatting at the same time. You can increase the limits on the number of file descriptors and the number of tasks in the Linux 2.2 kernel by following the steps below. These steps were performed on a Red Hat Linux 6.0 system using Linux kernel 2.2.5-15. The instructions may be different for your Linux system. To increase the maximum file descriptors per process to 4,096 (from 1,024) and the maximum tasks per user to 4,090 (from 256) on Linux 2.2, do the following steps.
LinuxThreads 0.7 limitsEven after you rebuild your Linux 2.2 kernel to increase the maximum number of threads per Linux user from 256 to 4,090, there are still definitions in the thread library itself which limit the number of threads per process to less than 1,000. The VolanoChat server requires two threads for each person chatting through a VolanoChat applet, so the LinuxThreads implementation creates a limit of 500 people to a single VolanoChat server. You can increase this limit to 8,192 threads with the following steps. Even though the thread library will allow 8,192 threads per process after these changes, you'll still be limited by the Linux 2.2 kernel to a maximum of 4,090 threads for the Linux user account running the VolanoChat server after the changes in the previous section. The steps below are shown for a Red Hat Linux 6.0 system, so they may be different for your Linux distribution.
Verifying the new file descriptor limitIncrease your new limits to their maximum by entering
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
void main(void) {
int k = 3;
while (dup(0) != -1)
k++;
printf("Opens = %d Fdsize = %d\n", k, sizeof(fd_set) * 8);
}
Both numbers printed should give your new file descriptor limit. Verifying the new thread limitYou can use the following program to verify your new thread limits in the modified Linux 2.2 kernel and in the modified LinuxThreads library.
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#define MAX_THREADS 10000
int i;
void run(void) {
char c;
if (i < 10)
printf("Address of c = %u KB\n", (unsigned int) &c / 1024);
sleep(60 * 60);
}
int main(int argc, char *argv[]) {
int rc = 0;
pthread_t thread[MAX_THREADS];
printf("Creating threads ...\n");
for (i = 0; i < MAX_THREADS && rc == 0; i++) {
rc = pthread_create(&(thread[i]), NULL, (void *) &run, NULL);
if (rc == 0) {
pthread_detach(thread[i]);
if ((i + 1) % 1000 == 0)
printf("%i threads so far ...\n", i + 1);
}
else
printf("Failed with return code %i creating thread %i.\n",
rc, i + 1);
}
exit(0);
}
Compile the program with: gcc -lpthread -o count count.c Running with the original LinuxThreads library will print: blue:/home/john> count Creating threads ... Address of c = 3137535 KB Address of c = 3135487 KB Address of c = 3133439 KB Address of c = 3131391 KB Address of c = 3129343 KB Address of c = 3127295 KB Address of c = 3125247 KB Address of c = 3123199 KB Address of c = 3121151 KB 1000 threads so far ... Failed with return code 11 creating thread 1023. while running with the modified LinuxThreads library will print: blue:/home/john> count Creating threads ... Address of c = 3144703 KB Address of c = 3144447 KB Address of c = 3144191 KB Address of c = 3143935 KB Address of c = 3143679 KB Address of c = 3143423 KB Address of c = 3143167 KB Address of c = 3142911 KB Address of c = 3142655 KB 1000 threads so far ... 2000 threads so far ... 3000 threads so far ... 4000 threads so far ... You may need to enter Notice that the thread stack addresses are spaced apart by 256 kilobytes instead of the earlier reserve of 2 megabytes per stack. Also notice that the program can create threads right up to the Linux 2.2 kernel limit of 4,090 for the system rather than the earlier LinuxThreads limit of 1,024 per process. TowerJ for LinuxYou can use the TowerJ High Performance Java Compiler from Tower Technology to run your VolanoChat server on Linux. TowerJ did very well in our latest benchmark tests of the VolanoChat server. After installing VolanoChat and Blackdown JDK 1.1.7 Version 3, you'll need to download the following additional files in order to run the TowerJ-compiled version of the VolanoChat server: ftp://ftp.volano.com/Main - 2,226,355 bytes ftp://ftp.volano.com/tjinterp.tjlib - 3,393,021 bytes ftp://ftp.volano.com/libtjrtl_t.so.31.0 - 670,053 bytes Place all three files in the VolanoChat installation directory,
called Define the following environment variables, shown below for the UNIX C Shell with an installation of VolanoChat and Blackdown JDK 1.1.7 Version 3 in your home directory: setenv TOWERJ_TJLIB_PATH $home/vchat2.1.3 setenv LD_LIBRARY_PATH $home/vchat2.1.3 setenv CLASSPATH .:$home/jdk117_v3/lib/classes.zip You can then start the TowerJ-compiled VolanoChat server by entering
the command
blue:/home/john/vchat2.1.3> Main
VolanoChat(TM) Server Version 2.1.3
Copyright (C) 1996-1999 Volano LLC. All rights reserved.
Loading server properties from /home/john/vchat2.1.3/properties.txt.
interp: Warning:
Error opening message file "/home/john/vchat2.1.3/lib/base.msg".
interp: Warning:
Error opening message file "/home/john/vchat2.1.3/lib/towerj.msg".
security properties not found. using defaults.
blue.volano.com (192.168.0.3) VolanoChatPro - 5 connection limit.
You can safely ignore the warning messages that are printed. |
| Copyright © 1999 Volano LLC. All rights reserved. |