Thread Safe and Scalability

Hi folks!

I am developing a server side component to interact with Jabber and listening request from several clients. However, after many tests, I realized that Smack uses until 4 threads per each XMPPConection object. packetReader have 2 threads and packetWriter have 2 more threads. I am testing with 3000 connections (that means more than 12000 threads) and the performances goes down severely, unfortunatelly my objective is to reach 10000 open and active connections. Any suggestions to do it with smack ?

thank you!

Max,

A good solution is to have as many connections as possible from one JVM and then start to use many JVMs per PC. Eventually, you may end up with many PCs running many JVMs running Smack with several connections. To get the highest number of connections per JVM and the number of JVMs per PC you’'ll have to finetune it by hand.

BTW, it’‘d be great to know the max numbers of simultaneous connections per JVM that you got until the performance started to go down. Please, don’'t forget to specify the PC characteristics.

Suerte,

– Gato

One other thing I’'d be interesting in exploring for a future Smack release is using NIO. That should allow us to use only a single thread for many connections, which would provide much more scalability.

-Matt

Gato, thank you for your comment. My server is an Athlon XP 2200+ with 768Mb RAM DDR333. I’'m using Linux 2.4 and my server slow down with 3000 connections (12000 threads with smack). The two problems are related with the stack space (never less than 96Kb in Java) and the time wasted in context switching. In Linux, thread context switching is in the order of 10 microseconds (10 * 10-6 seconds). So, multiply 1,2 * 104 * 10 * 10^-6 = 0,12 seconds!

a good solution is to use NIO and a single thread (or two) to process the whole stuff.

gracias!

Max

Max,

Another solution to consider is the new Linux thread library, which is much more scalable. It’'s in Redhat 9 as well as kernel 2.6. You can read more about it at:

http://java.sun.com/developer/technicalArticles/JavaTechandLinux/RedHat/

Regards,

Matt