directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niklas Therning <nik...@trillian.se>
Subject Re: [mina] Thread Pools, Concurrent connections and Performance
Date Tue, 27 Dec 2005 10:45:51 GMT
Alessandro Torrisi wrote:
> Hi ! I'm developing a free and opensource Direct Connect software (P2P 
> server). Now that protocol implementation is quite complete I'm testing 
> with lot of connections.
> When connections are made in a concurrent way (50-100 a time), the 
> server seems to be blocked...
> Can I do something to improve performance, adjusting some parameter or 
> applying some programming pattern directly on Mina ? I've listened about 
> Thread Pools on SocketAcceptor and IoThreadPool but I didn't find any 
> tutorial or documentation, is it possible to directly configure these 
> ones ?

Yes. By default the maximum thread pool size equals Integer.MAX_VALUE. 
It can be changed but this has changed bewteen MINA 0.8 and 0.9.

In 0.8, when using SimpleServiceRegistry, you can configure the maximum 
pool size like this:

IoThreadPoolFilter f = (IoThreadPoolFilter)
reg.getIoAcceptor(TransportType.SOCKET).getFilterChain().get("threadPool");
f.setMaximumPoolSize(10);

In 0.9 its not that easy since the ThreadPoolFilter used by 
SimpleServiceRegistry isn't accessible until a session has been created. 
You could try to extend SimpleServiceRegistry and configure the 
protected threadPoolFilter yourself:

public class MyServiceRegistry extends SimpleServiceRegistry {
     public MyServiceRegistry() {
         super();
         threadPoolFilter.setMaximumPoolSize(10);
     }
}

And then instead of using SimpleServiceRegistry you use MyServiceRegistry.

Both of these approaches will use a thread pool of at most 10 threads.

HTH
/Niklas

Mime
View raw message