UIL2 loadtesting and threads
amayingenta Jul 21, 2004 2:54 PMHi,
I've been trying to run some load tests against a remote server, and I'm finding that JBoss is using a lot of threads (and eventually can't create any more).
I have a MDB that's listening on a local queue, and replying to messages via the destination I'm setting as the JMSReplyTo on the Message. The work the MDB does is usually taking about 100ms, and both the request and reply are ObjectMessages.
My client application loops around sending a message, then waiting for the reply, so there is never more than one active MDB. The intention is that the ReplyTo destination would be a TemporaryQueue used for a single call, but I've tested with using a statically declared Queue on the remote machine and I get the same problem.
Each time I send and receive a Message there seem to be two threads created on the JBoss server. These threads seem to disappear after a while (30 seconds or something of that order). If I send the messages slowly this isn't a problem, but if I keep sending another message as soon as I get a reply then I soon have hundreds of threads, and eventually I run out of threads somewhere > 4000.
Looking at thread dumps the threads are doing:
"Thread-296" daemon prio=1 tid=0x089252d8 nid=0x4b36 in Object.wait() [60b9c000..60b9c87c] at java.lang.Object.wait(Native Method) - waiting on <0x475baa48> (a EDU.oswego.cs.dl.util.concurrent.LinkedNode) at EDU.oswego.cs.dl.util.concurrent.SynchronousChannel.poll(SynchronousChannel.java:353) - locked <0x475baa48> (a EDU.oswego.cs.dl.util.concurrent.LinkedNode) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor.getTask(PooledExecutor.java:723) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:747) at java.lang.Thread.run(Thread.java:534)
I'm using JBoss 3.2.5 (same problem with 3.2.3) on Mandrake 10.0 with Java 1.4.2_05. There's nothing else running on the server.
Here's a portion of my test case (in this version I'm using a statically declared Queue for the replies instead of a TemporaryQueue):
QueueConnection con = factory.createQueueConnection(); con.start(); QueueSession session = con.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE); QueueSender sender = session.createSender(queue); sender.setDeliveryMode(DeliveryMode.NON_PERSISTENT); QueueReceiver receiver = session.createReceiver(replyQueue); int i = 0; while (System.currentTimeMillis() - start < duration) { Query query = (Query)searches.get(i); Message message = session.createObjectMessage(query); message.setJMSReplyTo(replyQueue); long searchStart = System.currentTimeMillis(); sender.send(message); ObjectMessage reply = (ObjectMessage)receiver.receive(60000); Long time = new Long(System.currentTimeMillis() - searchStart); }
I had a similar test working with messaging inside the same JBoss server (between a session bean and the MDB using the JVM-IL) and I did not have this problem.
I'd appreciate any suggestions you can offer.
Thanks,
Andrew