On Tue, 2006-11-07 at 10:48 +0100, Sven Panko wrote: > For SocketAcceptor (or IoAcceptor) : > Executor executor1 = Executors.newFixedThreadPool(nbThread); > SocketAcceptor acceptor = new SocketAcceptor(nbThread, executor1); > > My feeling is that it shouldn't be a newCachedThreadPool here since > it seems it is relative to the number of SocketIoProcessors that > the SocketAcceptor will use. > By default (new SocketAcceptor() without arguments), it use > a value of 16 threads and SocketIoProcessors. > --- end quote > > What I do not understand is: why do I have to specify two numbers of > threads (one during the specification of the fixed thread pool and one > when constructing the socket acceptor)? Frederic sets both times an > identical value, but how are they related? Or is the first argument in the > SocketAcceptor constructor just an information how many (core) threads the > executor will use?
Hi sven I believe the default behaviour in MINA 1.0.0 is 1 SocketIoProcessor with a cached thread pool. Specifying a number of threads in: SocketAcceptor acceptor = new SocketAcceptor(nbThread, executor1); will dictate how many SocketIoProcessor(s) you want. A good start is 1 for single-cpu, 2 for dual-cpus (or dual core), etc... Basically 1 SocketIoProcessor per CPU although at some stage you need to run performance tests to adapt your app to your hardware and see what's best. Specifying a number of threads in: Executor executor1 = Executors.newFixedThreadPool(nbThread); will dictate how many threads are in the thread pool. Bear in mind the number of threads is fixed so if you have many clients connecting you may have issues here. To reproduce MINA's 1.0.0 default behaviour you need to use : Executor executor1 = Executors.newCachedThreadPool(); because then the pool can grow if necessary. I recommend you have a look at the Javadoc of the Java Concurrent Util backport. Example: Executor executor1 = Executors.newFixedThreadPool(10); SocketAcceptor acceptor = new SocketAcceptor(2, executor1); will setup 2 SocketIoProcessors sharing a thread pool of 10 threads. If you have more than 10 clients connecting and sending/receiving at the same time you may have pbms hence why depending on the intent of your app it may be better to use: Executor executor1 = Executors.newCachedThreadPool(); SocketAcceptor acceptor = new SocketAcceptor(2, executor1); in order to allow the pool to grow if need be. So to answer your question the two "nbThreads" value are not related. Pls anyone on the list correct me if I'm wrong. -- Frederic Soulier <[EMAIL PROTECTED]> OpenPGP key available on http://www.keyserver.net 1024D/BA6700ED 49A6 8E8E 4230 8D41 1ADE B649 3203 1DD2 BA67 00ED
