You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by Muhammad Farooq <mf...@i2cinc.com> on 2013/12/02 17:22:36 UTC

Mina Performance Issue

Hi Folks,

I am experiencing some performance issues with Apache Mina 2.0. The problem
is when more then 400 Mina client sends media data (around 300kb) to Mina
Server.
On full load Server receive messages too much late around 15-20
minutes late messages received at Server end.

The more strange thing is server's messageRecieved method still called and
receive data even after all clients stop sending data.
Seems like mina cache client's data somewhere.
(Don't know why and where it cache data).

I am using Mina 2.0 and Spring 3.0 both at Server and client end.
I have applied all Mina related performance setting in Server application
but no success. Below are some applied settings in server application.


<bean id="mediaCodecFilter"
class="org.apache.mina.filter.codec.ProtocolCodecFilter">
         <constructor-arg>
             <bean

class="org.apache.mina.filter.codec.serialization.ObjectSerilizationCodFactry">
                 <property name="encoderMaxObjectSize" value="52428800" 
/>    <!-- 50 MB -->
                 <property name="decoderMaxObjectSize" value="52428800" />
             </bean>
         </constructor-arg>
     </bean>


<bean id="minaThreadPool"
class="org.apache.mina.filter.executor.ExecutorFilter" scope="prototype">
         <constructor-arg name="corePoolSize" index="0" value="2000"  />
         <constructor-arg name="maximumPoolSize" index="1" value="3000"  />
         <constructor-arg name="keepAliveTime" index="2" value="30" />
         <constructor-arg name="unit" index="3" value="SECONDS"
type="java.util.concurrent.TimeUnit" />
     </bean>

<bean id="mediaFilterChainBuilder"
  class="org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder">

         <property name="filters">
             <map>
                 <entry key="loggingFilter" value-ref="loggingFilter" />
                 <entry key="codecFilter" value-ref="mediaCodecFilter" />
                 <entry key="executorFilter" value-ref="minaThreadPool" />
             </map>
         </property>
     </bean>


NioSocketAcceptor mediaAcceptor =
(NioSocketAcceptor)SpringUtilities.getInstance().getBean("mediaIoAcceptor");

         mediaAcceptor.getSessionConfig().setReceiveBufferSize( 8192 );
         mediaAcceptor.getSessionConfig().setIdleTime( 
IdleStatus.BOTH_IDLE, 30 );


We are using 64 bit Linux with 8 core CPU and 32 GB of memory.
Please help as i am stuck on this issue.

Thanks.


Re: Mina Performance Issue

Posted by Muhammad Farooq <mf...@i2cinc.com>.
Please Help, i am still facing same issue.

On 12/3/2013 8:39 PM, Muhammad Farooq wrote:
> Dear Emmanuel,
>
> Thank you for your response. Please see my comments in line.
>
> On 12/2/2013 10:24 PM, Emmanuel Lécharny wrote:
>> Le 12/2/13 5:22 PM, Muhammad Farooq a écrit :
>>> Hi Folks,
>>>
>>> I am experiencing some performance issues with Apache Mina 2.0.
>> Which exact version ?
>> exact version is 2.0.4
>>> The problem
>>> is when more then 400 Mina client sends media data (around 300kb) to 
>>> Mina
>>> Server.
>>> On full load Server receive messages too much late around 15-20
>>> minutes late messages received at Server end.
>> What is your network bandwith ? Java version ?
>> i am testing this scenario in our LAN enviourment 100 mbps. Java 
>> version is "1.6.0_22"
>>> The more strange thing is server's messageRecieved method still called
>>> and
>>> receive data even after all clients stop sending data.
>>> Seems like mina cache client's data somewhere.
>>> (Don't know why and where it cache data).
>> In the client's buffers. If the server can't read fast enough, then the
>> client will not be able to write until the socket get's ready, so that's
>> pretty normal.
>>
>>> I am using Mina 2.0 and Spring 3.0 both at Server and client end.
>>> I have applied all Mina related performance setting in Server 
>>> application
>>> but no success. Below are some applied settings in server application.
>>>
>>>
>>> <bean id="mediaCodecFilter"
>>> class="org.apache.mina.filter.codec.ProtocolCodecFilter">
>>>          <constructor-arg>
>>>              <bean
>>>
>>> class="org.apache.mina.filter.codec.serialization.ObjectSerilizationCodFactry"> 
>>>
>>>
>>>                  <property name="encoderMaxObjectSize" value="52428800"
>>> />    <!-- 50 MB -->
>>>                  <property name="decoderMaxObjectSize" 
>>> value="52428800" />
>>>              </bean>
>>>          </constructor-arg>
>>>      </bean>
>>>
>>>
>>> <bean id="minaThreadPool"
>>> class="org.apache.mina.filter.executor.ExecutorFilter" 
>>> scope="prototype">
>>>          <constructor-arg name="corePoolSize" index="0" 
>>> value="2000"  />
>>>          <constructor-arg name="maximumPoolSize" index="1"
>>> value="3000"  />
>>>          <constructor-arg name="keepAliveTime" index="2" value="30" />
>>>          <constructor-arg name="unit" index="3" value="SECONDS"
>>> type="java.util.concurrent.TimeUnit" />
>>>      </bean>
>>>
>>> <bean id="mediaFilterChainBuilder"
>>> class="org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder">
>>>
>>>          <property name="filters">
>>>              <map>
>>>                  <entry key="loggingFilter" 
>>> value-ref="loggingFilter" />
>>>                  <entry key="codecFilter" 
>>> value-ref="mediaCodecFilter" />
>>>                  <entry key="executorFilter" 
>>> value-ref="minaThreadPool" />
>>>              </map>
>>>          </property>
>>>      </bean>
>>>
>>>
>>> NioSocketAcceptor mediaAcceptor =
>>> (NioSocketAcceptor)SpringUtilities.getInstance().getBean("mediaIoAcceptor"); 
>>>
>>>
>>>
>>> mediaAcceptor.getSessionConfig().setReceiveBufferSize( 8192 );
>> Way to small. Set it to something like 64Kb. That will allow your server
>> to read bigger chunks of data in one shot.
> I will surely try after increasing size.
>> Also are you CPU bounded ? Or is your processor doing nothing while
>> processing the requests ?
>>
>> No my application is not CPU bounded and CPU remians around 50% idle 
>> while
>>   processing requests.
>
>


Re: Mina Performance Issue

Posted by Bernd Fondermann <be...@gmail.com>.
On a general note, it's rather hard to help you from the MINA point of
view, because although you use MINA, you are not asking a MINA-specific
question. Just as a comparison, this could just as well be a problem in
your own code (synchronized etc.) or on OS-level as this could be a MINA
problem. It would be helpful if you'd be able to track down the problem a
little bit more (for example by sniffing network activity).

On a more specific note:

> The problem
>>> is when more then 400 Mina client sends media data (around 300kb) to Mina
>>> Server.
>>> On full load Server receive messages too much late around 15-20
>>> minutes late messages received at Server end.
>>>
>> What is your network bandwith ? Java version ?
>> i am testing this scenario in our LAN enviourment 100 mbps. Java version
>> is "1.6.0_22"
>
>
400 client each sending 300kb. in total, this is 120MB.
Question: what is the timing? 300kb per second? per minute? you might
saturate your server's network link here.

  Bernd

Re: Mina Performance Issue

Posted by Muhammad Farooq <mf...@i2cinc.com>.
Dear Emmanuel,

Thank you for your response. Please see my comments in line.

On 12/2/2013 10:24 PM, Emmanuel Lécharny wrote:
> Le 12/2/13 5:22 PM, Muhammad Farooq a écrit :
>> Hi Folks,
>>
>> I am experiencing some performance issues with Apache Mina 2.0.
> Which exact version ?
> exact version is 2.0.4
>> The problem
>> is when more then 400 Mina client sends media data (around 300kb) to Mina
>> Server.
>> On full load Server receive messages too much late around 15-20
>> minutes late messages received at Server end.
> What is your network bandwith ? Java version ?
> i am testing this scenario in our LAN enviourment 100 mbps. Java version is "1.6.0_22"
>> The more strange thing is server's messageRecieved method still called
>> and
>> receive data even after all clients stop sending data.
>> Seems like mina cache client's data somewhere.
>> (Don't know why and where it cache data).
> In the client's buffers. If the server can't read fast enough, then the
> client will not be able to write until the socket get's ready, so that's
> pretty normal.
>
>> I am using Mina 2.0 and Spring 3.0 both at Server and client end.
>> I have applied all Mina related performance setting in Server application
>> but no success. Below are some applied settings in server application.
>>
>>
>> <bean id="mediaCodecFilter"
>> class="org.apache.mina.filter.codec.ProtocolCodecFilter">
>>          <constructor-arg>
>>              <bean
>>
>> class="org.apache.mina.filter.codec.serialization.ObjectSerilizationCodFactry">
>>
>>                  <property name="encoderMaxObjectSize" value="52428800"
>> />    <!-- 50 MB -->
>>                  <property name="decoderMaxObjectSize" value="52428800" />
>>              </bean>
>>          </constructor-arg>
>>      </bean>
>>
>>
>> <bean id="minaThreadPool"
>> class="org.apache.mina.filter.executor.ExecutorFilter" scope="prototype">
>>          <constructor-arg name="corePoolSize" index="0" value="2000"  />
>>          <constructor-arg name="maximumPoolSize" index="1"
>> value="3000"  />
>>          <constructor-arg name="keepAliveTime" index="2" value="30" />
>>          <constructor-arg name="unit" index="3" value="SECONDS"
>> type="java.util.concurrent.TimeUnit" />
>>      </bean>
>>
>> <bean id="mediaFilterChainBuilder"
>>   class="org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder">
>>
>>          <property name="filters">
>>              <map>
>>                  <entry key="loggingFilter" value-ref="loggingFilter" />
>>                  <entry key="codecFilter" value-ref="mediaCodecFilter" />
>>                  <entry key="executorFilter" value-ref="minaThreadPool" />
>>              </map>
>>          </property>
>>      </bean>
>>
>>
>> NioSocketAcceptor mediaAcceptor =
>> (NioSocketAcceptor)SpringUtilities.getInstance().getBean("mediaIoAcceptor");
>>
>>
>>          mediaAcceptor.getSessionConfig().setReceiveBufferSize( 8192 );
> Way to small. Set it to something like 64Kb. That will allow your server
> to read bigger chunks of data in one shot.
I will surely try after increasing size.
> Also are you CPU bounded ? Or is your processor doing nothing while
> processing the requests ?
>
> No my application is not CPU bounded and CPU remians around 50% idle while
>   processing requests.


Re: Mina Performance Issue

Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 12/2/13 5:22 PM, Muhammad Farooq a écrit :
> Hi Folks,
>
> I am experiencing some performance issues with Apache Mina 2.0. 

Which exact version ?

> The problem
> is when more then 400 Mina client sends media data (around 300kb) to Mina
> Server.
> On full load Server receive messages too much late around 15-20
> minutes late messages received at Server end.

What is your network bandwith ? Java version ?

>
> The more strange thing is server's messageRecieved method still called
> and
> receive data even after all clients stop sending data.
> Seems like mina cache client's data somewhere.
> (Don't know why and where it cache data).

In the client's buffers. If the server can't read fast enough, then the
client will not be able to write until the socket get's ready, so that's
pretty normal.

>
> I am using Mina 2.0 and Spring 3.0 both at Server and client end.
> I have applied all Mina related performance setting in Server application
> but no success. Below are some applied settings in server application.
>
>
> <bean id="mediaCodecFilter"
> class="org.apache.mina.filter.codec.ProtocolCodecFilter">
>         <constructor-arg>
>             <bean
>
> class="org.apache.mina.filter.codec.serialization.ObjectSerilizationCodFactry">
>
>                 <property name="encoderMaxObjectSize" value="52428800"
> />    <!-- 50 MB -->
>                 <property name="decoderMaxObjectSize" value="52428800" />
>             </bean>
>         </constructor-arg>
>     </bean>
>
>
> <bean id="minaThreadPool"
> class="org.apache.mina.filter.executor.ExecutorFilter" scope="prototype">
>         <constructor-arg name="corePoolSize" index="0" value="2000"  />
>         <constructor-arg name="maximumPoolSize" index="1"
> value="3000"  />
>         <constructor-arg name="keepAliveTime" index="2" value="30" />
>         <constructor-arg name="unit" index="3" value="SECONDS"
> type="java.util.concurrent.TimeUnit" />
>     </bean>
>
> <bean id="mediaFilterChainBuilder"
>  class="org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder">
>
>         <property name="filters">
>             <map>
>                 <entry key="loggingFilter" value-ref="loggingFilter" />
>                 <entry key="codecFilter" value-ref="mediaCodecFilter" />
>                 <entry key="executorFilter" value-ref="minaThreadPool" />
>             </map>
>         </property>
>     </bean>
>
>
> NioSocketAcceptor mediaAcceptor =
> (NioSocketAcceptor)SpringUtilities.getInstance().getBean("mediaIoAcceptor");
>
>
>         mediaAcceptor.getSessionConfig().setReceiveBufferSize( 8192 );

Way to small. Set it to something like 64Kb. That will allow your server
to read bigger chunks of data in one shot.

Also are you CPU bounded ? Or is your processor doing nothing while
processing the requests ?


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com