You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Stéphane Hanser <s....@omegames.com> on 2007/06/01 10:48:52 UTC

WebApp really slow, Where do I start looking?

Hello,

I've been working on my project for months now, it is my first WebApp 
project. Yesterday, I deployed the project on my dedicated server and a 
soon as I reached about 80 users, the webapp became really slow. 
However, the cpu usage of the server was very low (never more than 
15-20%). I have no idea of what is the cause of this slowness (server 
config, bad programming..).

Can someone help me to diagnostic the problem? Where shoul I start looking?

thanks in advance,

Stéphane H.





---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: WebApp really slow, Where do I start looking?

Posted by David Delbecq <de...@oma.be>.
Queueing request will get you in same situation as if you put a big
synchronized block around all your code. You should reduce the size of
synchronized block to the smallest amount of time possible to limit
threads waiting (and as such avoid long working synchronized methods).
If possible, if an object is synchronized and takes time to work,
duplicate this object in each request instead of sharing one amongst all
users. Most of the time, your code won't need lots synchronized blocks
(for example, if data are stored on a db, use one separate connection
for each request instead of having an accessor object sharing connection
amongst users).

En l'instant précis du 01/06/07 12:25, Stéphane Hanser s'exprimait en
ces termes:
> You are right about synchronized blocks. I removed every synchronized
> instruction for tests purposes and it "unleashed the cpu" ;)
>
> It may be a problem with memory too. By disabling the cache of iBatis I
> noticed an overloading of the CPU, which is understandable considering the
> circumstance.
>
> However, removing some synchronized blocks will cause concurrent access
> issues when a user "mass clicks". Is it possible to configure tomcat to
> queue one's requests instead of executing the in parallel ?
>
> Thanks,
>
> Stéphane H.
>
> PS: thanks for the jmeter tip ;)
>
>
> -----Message d'origine-----
> De : David Delbecq [mailto:delbd+jakarta@oma.be] 
> Envoyé : vendredi 1 juin 2007 10:59
> À : Tomcat Users List
> Objet : Re: WebApp really slow, Where do I start looking?
>
> Considering CPU usage, it is not
> 1) a java memory problem, if java memory was full, garbage collector
> would start using lots of cpu
> 2) a time consuming java code.
>
> It might be one of following
> 1) synchronized blocks in your code, that would prevent 2 simultaneoous
> users from doing some operations.
> 2) use of SingleThreadModel, which has same effect as above
> 3) Network congestion, you server simply can't send the response to
> client due to a too small network pipe (80 requests / second resulting
> each in an about 20k response need a bandwidth of more than 12Mbits)
> 4) A too small physical memory on system. Eg you configure tomcat to use
> 1G memory but your server has only 512M available, resulting in memory
> pagination (swap) and sleeping of java process during pagination process
> (typically, on unix server, you will see a high % of CPU dedicated to
> system instead of idle when this happen)
>
>
> One way to test your server performance during heavy is to use apache
> jmeter.
>
>
> En l'instant précis du 01/06/07 10:48, Stéphane Hanser s'exprimait en
> ces termes:
>   
>> Hello,
>>
>> I've been working on my project for months now, it is my first WebApp
>> project. Yesterday, I deployed the project on my dedicated server and
>> a soon as I reached about 80 users, the webapp became really slow.
>> However, the cpu usage of the server was very low (never more than
>> 15-20%). I have no idea of what is the cause of this slowness (server
>> config, bad programming..).
>>
>> Can someone help me to diagnostic the problem? Where shoul I start
>> looking?
>>
>> thanks in advance,
>>
>> Stéphane H.
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>     
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>   



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: WebApp really slow, Where do I start looking?

Posted by Peter Crowther <Pe...@melandra.com>.
> From: Stéphane Hanser [mailto:s.hanser@omegames.com] 
> However, removing some synchronized blocks will cause 
> concurrent access
> issues when a user "mass clicks". Is it possible to configure 
> tomcat to
> queue one's requests instead of executing the in parallel ?

Not in all cases.  The browser is free to make new requests to a web server; it would be up to your code to detect that they came from the same session and take appropriate actions.  In general, if a user mass-clicks, you actually want to process the most recent as the browser will no longer take responses fr the older requests...

If you're concerned about multiple clicks on submit buttons, there are well-known ways to use Javascript to disable the button once the user clicks it the first time.

		- Peter

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: WebApp really slow, Where do I start looking?

Posted by Leon Rosenberg <ro...@googlemail.com>.
start with monitoring. Find out which action/servlet/whatever is
taking time. Go further down and check where the time is spent (a
service object or something). Narrow it down, than solve it :-)

regards
Leon

>
> On 6/1/07, Stéphane Hanser <s....@omegames.com> wrote:
> > You are right about synchronized blocks. I removed every synchronized
> > instruction for tests purposes and it "unleashed the cpu" ;)
> >
> > It may be a problem with memory too. By disabling the cache of iBatis I
> > noticed an overloading of the CPU, which is understandable considering the
> > circumstance.
> >
> > However, removing some synchronized blocks will cause concurrent access
> > issues when a user "mass clicks". Is it possible to configure tomcat to
> > queue one's requests instead of executing the in parallel ?
> >
> > Thanks,
> >
> > Stéphane H.
> >
> > PS: thanks for the jmeter tip ;)
> >
> >
> > -----Message d'origine-----
> > De: David Delbecq [mailto:delbd+jakarta@oma.be]
> > Envoyé: vendredi 1 juin 2007 10:59
> > À: Tomcat Users List
> > Objet: Re: WebApp really slow, Where do I start looking?
> >
> > Considering CPU usage, it is not
> > 1) a java memory problem, if java memory was full, garbage collector
> > would start using lots of cpu
> > 2) a time consuming java code.
> >
> > It might be one of following
> > 1) synchronized blocks in your code, that would prevent 2 simultaneoous
> > users from doing some operations.
> > 2) use of SingleThreadModel, which has same effect as above
> > 3) Network congestion, you server simply can't send the response to
> > client due to a too small network pipe (80 requests / second resulting
> > each in an about 20k response need a bandwidth of more than 12Mbits)
> > 4) A too small physical memory on system. Eg you configure tomcat to use
> > 1G memory but your server has only 512M available, resulting in memory
> > pagination (swap) and sleeping of java process during pagination process
> > (typically, on unix server, you will see a high % of CPU dedicated to
> > system instead of idle when this happen)
> >
> >
> > One way to test your server performance during heavy is to use apache
> > jmeter.
> >
> >
> > En l'instant précis du 01/06/07 10:48, Stéphane Hanser s'exprimait en
> > ces termes:
> > > Hello,
> > >
> > > I've been working on my project for months now, it is my first WebApp
> > > project. Yesterday, I deployed the project on my dedicated server and
> > > a soon as I reached about 80 users, the webapp became really slow.
> > > However, the cpu usage of the server was very low (never more than
> > > 15-20%). I have no idea of what is the cause of this slowness (server
> > > config, bad programming..).
> > >
> > > Can someone help me to diagnostic the problem? Where shoul I start
> > > looking?
> > >
> > > thanks in advance,
> > >
> > > Stéphane H.
> > >
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To start a new topic, e-mail: users@tomcat.apache.org
> > > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > > For additional commands, e-mail: users-help@tomcat.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: [OT] Arithmetic Exception

Posted by Dwight Farris <df...@email.arizona.edu>.
Thanks for the response; I will check the code.
Dwight

At 08:52 AM 6/1/2007, you wrote:
> > From: Dwight Farris [mailto:dfarris@email.arizona.edu]
> > Subject: Arithmetic Exception
> >
> > I am receiving what I interpret as a 'divide by zero' error -
> >
> > java.lang.ArithmeticException: / by zero
> >          at
> > edu.uc.cohorts.util.Util.calcCohortAllotment(Util.java:123)
>
>"Doctor, doctor, it hurts when I do this!"
>
>This is an error in the code of your webapp; as good as Tomcat is, it
>can't correct basic programming errors in user code.  The exception is
>telling you exactly where to look for the problem.
>
>You need to either check for zero before the divide, or catch the
>exception in your code, or configure an error page for the situation if
>you want to display something pretty to the end user.
>
>  - Chuck
>
>
>THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
>MATERIAL and is thus for use only by the intended recipient. If you
>received this in error, please contact the sender and delete the e-mail
>and its attachments from all computers.
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: [OT] Arithmetic Exception

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Dwight Farris [mailto:dfarris@email.arizona.edu] 
> Subject: Arithmetic Exception
> 
> I am receiving what I interpret as a 'divide by zero' error -
> 
> java.lang.ArithmeticException: / by zero
>          at 
> edu.uc.cohorts.util.Util.calcCohortAllotment(Util.java:123)

"Doctor, doctor, it hurts when I do this!"

This is an error in the code of your webapp; as good as Tomcat is, it
can't correct basic programming errors in user code.  The exception is
telling you exactly where to look for the problem.

You need to either check for zero before the divide, or catch the
exception in your code, or configure an error page for the situation if
you want to display something pretty to the end user.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Arithmetic Exception

Posted by Dwight Farris <df...@email.arizona.edu>.
Hello Everyone,
I am receiving what I interpret as a 'divide by zero' error -

StandardWrapperValve[action]: Servlet.service() for servlet action 
threw exception
java.lang.ArithmeticException: / by zero
         at edu.uc.cohorts.util.Util.calcCohortAllotment(Util.java:123)
         at 
edu.uc.cohorts.util.CohortAssignmentDB.AssignCohort(CohortAssignmentDB.java:720)


The class code for the string calcCohortAllotment  is below -

string = calcCohortAllotment
string = (Ljava/lang/Integer;)Ljava/lang/String;
name = calcCohortAllotment, descriptor=(Ljava/lang/integer;)Ljava/lang/String;
class = edu/uc/cohorts/util/Util; name=calcCohortAllotment, 
descriptor=(Ljava/lang/integer;)Ljava/lang/String;
string = ok

Any assistance is greatly appreciated,
Dwight

Re: WebApp really slow, Where do I start looking?

Posted by Larry Meadors <lm...@apache.org>.
Are the database and the tomcat server on the same machine?

Can you explain a little more about your synchronized code? I have
done several really big web apps with iBATIS, and haven't needed to
sync anything...

Larry


On 6/1/07, Stéphane Hanser <s....@omegames.com> wrote:
> You are right about synchronized blocks. I removed every synchronized
> instruction for tests purposes and it "unleashed the cpu" ;)
>
> It may be a problem with memory too. By disabling the cache of iBatis I
> noticed an overloading of the CPU, which is understandable considering the
> circumstance.
>
> However, removing some synchronized blocks will cause concurrent access
> issues when a user "mass clicks". Is it possible to configure tomcat to
> queue one's requests instead of executing the in parallel ?
>
> Thanks,
>
> Stéphane H.
>
> PS: thanks for the jmeter tip ;)
>
>
> -----Message d'origine-----
> De: David Delbecq [mailto:delbd+jakarta@oma.be]
> Envoyé: vendredi 1 juin 2007 10:59
> À: Tomcat Users List
> Objet: Re: WebApp really slow, Where do I start looking?
>
> Considering CPU usage, it is not
> 1) a java memory problem, if java memory was full, garbage collector
> would start using lots of cpu
> 2) a time consuming java code.
>
> It might be one of following
> 1) synchronized blocks in your code, that would prevent 2 simultaneoous
> users from doing some operations.
> 2) use of SingleThreadModel, which has same effect as above
> 3) Network congestion, you server simply can't send the response to
> client due to a too small network pipe (80 requests / second resulting
> each in an about 20k response need a bandwidth of more than 12Mbits)
> 4) A too small physical memory on system. Eg you configure tomcat to use
> 1G memory but your server has only 512M available, resulting in memory
> pagination (swap) and sleeping of java process during pagination process
> (typically, on unix server, you will see a high % of CPU dedicated to
> system instead of idle when this happen)
>
>
> One way to test your server performance during heavy is to use apache
> jmeter.
>
>
> En l'instant précis du 01/06/07 10:48, Stéphane Hanser s'exprimait en
> ces termes:
> > Hello,
> >
> > I've been working on my project for months now, it is my first WebApp
> > project. Yesterday, I deployed the project on my dedicated server and
> > a soon as I reached about 80 users, the webapp became really slow.
> > However, the cpu usage of the server was very low (never more than
> > 15-20%). I have no idea of what is the cause of this slowness (server
> > config, bad programming..).
> >
> > Can someone help me to diagnostic the problem? Where shoul I start
> > looking?
> >
> > thanks in advance,
> >
> > Stéphane H.
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: WebApp really slow, Where do I start looking?

Posted by Stéphane Hanser <s....@omegames.com>.
You are right about synchronized blocks. I removed every synchronized
instruction for tests purposes and it "unleashed the cpu" ;)

It may be a problem with memory too. By disabling the cache of iBatis I
noticed an overloading of the CPU, which is understandable considering the
circumstance.

However, removing some synchronized blocks will cause concurrent access
issues when a user "mass clicks". Is it possible to configure tomcat to
queue one's requests instead of executing the in parallel ?

Thanks,

Stéphane H.

PS: thanks for the jmeter tip ;)


-----Message d'origine-----
De : David Delbecq [mailto:delbd+jakarta@oma.be] 
Envoyé : vendredi 1 juin 2007 10:59
À : Tomcat Users List
Objet : Re: WebApp really slow, Where do I start looking?

Considering CPU usage, it is not
1) a java memory problem, if java memory was full, garbage collector
would start using lots of cpu
2) a time consuming java code.

It might be one of following
1) synchronized blocks in your code, that would prevent 2 simultaneoous
users from doing some operations.
2) use of SingleThreadModel, which has same effect as above
3) Network congestion, you server simply can't send the response to
client due to a too small network pipe (80 requests / second resulting
each in an about 20k response need a bandwidth of more than 12Mbits)
4) A too small physical memory on system. Eg you configure tomcat to use
1G memory but your server has only 512M available, resulting in memory
pagination (swap) and sleeping of java process during pagination process
(typically, on unix server, you will see a high % of CPU dedicated to
system instead of idle when this happen)


One way to test your server performance during heavy is to use apache
jmeter.


En l'instant précis du 01/06/07 10:48, Stéphane Hanser s'exprimait en
ces termes:
> Hello,
>
> I've been working on my project for months now, it is my first WebApp
> project. Yesterday, I deployed the project on my dedicated server and
> a soon as I reached about 80 users, the webapp became really slow.
> However, the cpu usage of the server was very low (never more than
> 15-20%). I have no idea of what is the cause of this slowness (server
> config, bad programming..).
>
> Can someone help me to diagnostic the problem? Where shoul I start
> looking?
>
> thanks in advance,
>
> Stéphane H.
>
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: WebApp really slow, Where do I start looking?

Posted by David Delbecq <de...@oma.be>.
Considering CPU usage, it is not
1) a java memory problem, if java memory was full, garbage collector
would start using lots of cpu
2) a time consuming java code.

It might be one of following
1) synchronized blocks in your code, that would prevent 2 simultaneoous
users from doing some operations.
2) use of SingleThreadModel, which has same effect as above
3) Network congestion, you server simply can't send the response to
client due to a too small network pipe (80 requests / second resulting
each in an about 20k response need a bandwidth of more than 12Mbits)
4) A too small physical memory on system. Eg you configure tomcat to use
1G memory but your server has only 512M available, resulting in memory
pagination (swap) and sleeping of java process during pagination process
(typically, on unix server, you will see a high % of CPU dedicated to
system instead of idle when this happen)


One way to test your server performance during heavy is to use apache
jmeter.


En l'instant précis du 01/06/07 10:48, Stéphane Hanser s'exprimait en
ces termes:
> Hello,
>
> I've been working on my project for months now, it is my first WebApp
> project. Yesterday, I deployed the project on my dedicated server and
> a soon as I reached about 80 users, the webapp became really slow.
> However, the cpu usage of the server was very low (never more than
> 15-20%). I have no idea of what is the cause of this slowness (server
> config, bad programming..).
>
> Can someone help me to diagnostic the problem? Where shoul I start
> looking?
>
> thanks in advance,
>
> Stéphane H.
>
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org