directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alessandro Torrisi <alessandro.torr...@eurone.it>
Subject Re: [mina] Thread Pools, Concurrent connections and Performance
Date Tue, 27 Dec 2005 14:26:20 GMT
I'm really happy for your great availability...here it is the 
opensource...that's what I like and probably love.
Yes it's hosted at sourceforge ! The project name is JxHub and here it 
is the url: http://www.sourceforge.net/projects/jxhub
Most of the protocol is implemented, it seems to go well..but you know 
the rest of the story...

Tell me if you want to access the cvs repository with other permissions.

Meanwhile I'm going to try the snippet for 0.9.x ... (I'm using Mina 
Snapshot 0.9.1 I tryied this for the bind problem on Unix, I wrote also 
for this one in the mailing list...I have to wait a minute or more for 
port unbind ! But this is the minor problem for now...)

Best regards Niklas
Bye, Alex

Niklas Therning wrote:

> Alessandro Torrisi wrote:
>
>> IoThreadPoolFilter f = (IoThreadPoolFilter)
>> reg.getIoAcceptor(TransportType.SOCKET).getFilterChain().get("threadPool"); 
>>
>> f.setMaximumPoolSize(10);
>>
>> I discovered that this piece of code gives me  
>> "NullPointerException", I have no FilterChain applied to the Acceptor 
>> and in my Eclipse debugger I can see:
>
>
> From what I can tell from the code you have included below you are 
> using MINA 0.9. As I explained in my previous mail the code above will 
> only work in MINA 0.8 (in 0.9 you will get an NPE since f will be 
> null). In MINA 0.9 you can try to to extend SimpleServiceRegistry 
> instead as I described earlier:
>
> public class MyServiceRegistry extends SimpleServiceRegistry {
>     public MyServiceRegistry() {
>         super();
>         threadPoolFilter.setMaximumPoolSize(10);
>     }
> }
>
> Please note that the most important thing for scalability is that you 
> never perform any blocking operations in your IoHandler 
> implementation. Or at least make sure that they only block for a very 
> short time. The code samples you included do not give enough 
> information on whether you have any blocking operations.
>
>> ...
>>
>> I'm stopped ! I don't know where to look. I think there's too little 
>> documentation or too few examples for Mina, I think more complex 
>> samples are needed !
>> Regards, Alex
>
>
> Yes, you may be right about that. But your open source DC server will 
> be an excellent example of a more complex MINA application. In the 
> meantime the MINA community is here to help you out.
>
> BTW, is your open source project hosted somewhere publicly like on 
> sourceforge? If it is I could have a look if you want to.
>
> /Niklas
>
>>
>> Niklas Therning wrote:
>>
>>> No, the number of threads in your thread pool does not limit the 
>>> number of concurrent clients. That's actually one of the big 
>>> benefits of using MINA. Since everything is event based you can use 
>>> a small number of threads to handle a larger number of connections.
>>>
>>> Please, try to set the max pool size to a small number (5-10 maybe) 
>>> and see if this has any impact on the performance.
>>>
>>> /Niklas
>>>
>>> Alessandro Torrisi wrote:
>>>
>>>> But in this way I will limit users max number in the hub server I 
>>>> think...
>>>> Is there any way to have a significant increase of performance ?
>>>>
>>>> Regards,
>>>> Alex.
>>>>
>>>>
>>>> Niklas Therning wrote:
>>>>
>>>>> 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