>>>>> "marc" == marc fleury <[EMAIL PROTECTED]> writes:
marc> here is the interesting bit, we kill linux with 300 threads
marc> and 30xload in CPU while a smaller windows box (2000) goes
marc> up to 1000 threads and at 300 threads is at 50% load....
The 30x load just means that 30 processes are ready to run. You'd
need to look at another stat to find out what percentage of the
CPU is in use. top will tell you. The load average is interesting,
but it's pretty system specific. A load average of 30 on a single
processor machine is probably pretty serious, but on a 32 processor
system it would mean that at least one processor was idle. I've
worked on a 8 processor Alpha with load averages at 170 or so, and
emacs ran just fine :-).
Linux is different from almost every other OS in the way it handles
threading. Linux doesn't really draw a clear distinction between
threads and processes - they're treated the same for scheduling
purposes, the only difference between a thread and process is how much
of their parents memory they can see.
In the default configuration of most Linux kernels, there is a maximum
of 512 processes and/or threads, which is a compiled-in limit (at
least up through 2.2 - I haven't checked 2.4). A normal user by
default can only create a maximum of 256 processes/threads, so your
load test is doomed to failure on most Linux systems, at least with a
JVM which uses native threads. A green threads JVM would most likely
survive it, though, although then you lose scalability on SMP systems.
marc> hummmmm we must be missing something
Typically, in a case like this, the answer is thread pools. You would
create enough worker threads to keep each processor in the system busy,
and then let the client requests be handled by a thread in the pool.
The rule of thumb is to create a thread per CPU, plus a thread for each
thread you expect to be blocked on I/O, plus one or two more just be
sure. It's definitely easier said than done, but it's definitely
preferable to running the system out of threads.
It works pretty well on Windows, too.