Ok, I don't have this all cleaned up, there are some issues that I have not yet resolved. However, I am very sure that there are much too many threads created by the media server. See :
http://www.javaspecialists.eu/archive/Issue149.html
I've been running a test with much less threads.
In the receiver, mms originally had two threads per endpoint: udp receiver which transfers media from the socket to a jitter buffer, and recevier thread, scheduled to fire every packet interval, to send media from the jitter buffer into the mms media paths. Using NIO, I was able to drop that down. In my test, there is one selector thread which transfers media from the ready socket into the right jitter buffer, and a few threads (probably too many), scheduled from a pool, which send media from jitter buffer into mms media paths.
In the transmitter, mms originally created three threads per endpoint. One is scheduled every packet interval to get data from a source and send it. Then one thread each for command and event processing. I've reduced these down to a handful, system wide. A few in a scheduled pool for transmitting (probably too many), one for events and one for commands (probably, too many).
In the audio player, mms originally created one thread per player for command processing. I reduced this down to one for the whole system.
Overall, for example, with 200 ivr endpoints, mms originally would create 1200 threads. The load test platform has only two cores! My changes reduces the number of threads to 15 or so.
The system runs linux which has a tool called vmstat. vmstat reports average count of runnable processes and threads (which are kind of indistinguishable by linux and vmstat) and the cpu utilization.
In a comparitive test of 250 ivr calls, vmstat would report:
Original mms (cr5)
runq between 12-220, cpu: user: 53%, sys: 46%, idle: 1%
Now, vmstat reports:
runq between 1-16, cpu: user: 41%, sys: 21%, idle: 38%
This is preliminary. I wanted to share this now because I have to take a break for a few days. I don't know if such information would affect your milestone schedule.
I'm looking forward to hearing your thoughts on this.
One of my concerns is blocking on read of the audio file. Am I underestimating its impact? (linux buffers file data in core memory. So in my load tests, there is probably little disk access for an 8MB file, but different story if every announcement is a different file.)
Also, about nio, it has a good buffer class: ByteBuffer which is 'native' to the nio api and is useful to the application as well. This means, adopting nio and its ByteBuffer can lead to less data copying. I see that data copying is internal to the demux, IIRC. ByteBuffer has a 'read only' protection that might help eliminate the need for a copy there.
Regards,
John