This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Performance and the fly likes what's the reason for poor performance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "what Watch "what New topic
Author

what's the reason for poor performance

David Yin
Greenhorn

Joined: Jan 18, 2011
Posts: 2
Hi Geeks,

I have a question here. Our team is developing a web application using Java, ICEFace and MySql for a while. When we test it on local, some functional button (complicated logic on the back-end and may contains thousands records search ) takes 2 or 3 second response time, which is acceptable. But after deploying it in the real web server, it takes 30 sec, sometimes even more than 1 min. We already do part of Mysql tuning but still not fast enough. I'm not sure it is because poor query or some poor code like much collections (link to other class) inside one super big class . Any suggestion?

Does somebody know any good testing tools can help us find the problem.



Thanks,
David
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 489
    
    5
I imagine your system flow would be something like
(1)....Browser....(2).....Network.......(3)....Web server application logic....(4)...Web server DAO.....(6).....Network to database server?.....(7)....MySQL query processing....(8)

The latency problem may lie between any pair of consecutive points.
The only tool I know which can profile this kind of end-to-end flow is dynatrace. But I know it only by reputation - have never tried it. You may want to look into if you're intent on a tool.

A simpler approach would be to add some timing output logs into your code flow and isolate where the delay is occurring.
If it's not possible to add output logs for some reason (if it's a production server which can't be stopped), then you can add traces safely and dynamically using Btrace (it can attach to your running tomcat or other java server) and get a clue where the problem is.
David Yin
Greenhorn

Joined: Jan 18, 2011
Posts: 2
Yes. The system flow is exactly what you said. The timing output is a good idea. Thank you for that.

But I'm sure the most problem is in the code, maybe some in DB configuration, and just few in browser/network/hardware. So I'm looking for a way that can do optimization without changing lot of stuff, and a free tool for me to test the performance. dynatrace looks like not free.





Karthik Shiraly wrote:I imagine your system flow would be something like
(1)....Browser....(2).....Network.......(3)....Web server application logic....(4)...Web server DAO.....(6).....Network to database server?.....(7)....MySQL query processing....(8)

The latency problem may lie between any pair of consecutive points.
The only tool I know which can profile this kind of end-to-end flow is dynatrace. But I know it only by reputation - have never tried it. You may want to look into if you're intent on a tool.

A simpler approach would be to add some timing output logs into your code flow and isolate where the delay is occurring.
If it's not possible to add output logs for some reason (if it's a production server which can't be stopped), then you can add traces safely and dynamically using Btrace (it can attach to your running tomcat or other java server) and get a clue where the problem is.
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

David Yin wrote:So I'm looking for a way that can do optimization without changing lot of stuff, and a free tool for me to test the performance. dynatrace looks like not free.


There is no such tool. You can tweak the system to go a bit faster, but in the end, you need to profile the system to find the bottleneck.

When you test on your local computer, do you really have the production database or just a fragment of it? If you don't have the full database to profile against, try getting one instance that have, say in your test environment. Then start profiling on the requests where it takes time.

It might not be that big of an issue to find the code that are hogging the CPU and change it. Just a couple of months ago, we found an old SQL-query that was good when the system had the version 1.0 but now, in version 6.2, the database and the table has been modified in such a way that the SQL was now getting a HUGE record set that had to be parsed in a EVEN HUGER for-loop to get the result. A remove of the * in the select, removal off the evil for-loop and an additional change in four lines of code and everything is now running smoothly.

I sometimes use the Splunk log tool to analyze the different logs when multiple servers is used.
Rojan punn
Greenhorn

Joined: Nov 29, 2011
Posts: 17


Like our friends said there is no easy way to improve performance!!

Did you try running the same query in the production DB server itself?If not i would suggest to do that first. and check the time taken to execute the query
Do you have a DB server in same machine as web server?
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7503
    
  18

David Yin wrote:But I'm sure the most problem is in the code, maybe some in DB configuration, and just few in browser/network/hardware. So I'm looking for a way that can do optimization without changing lot of stuff, and a free tool for me to test the performance.

Without your code (which I understand is not possible) it's impossible to say, but from what you describe it seems highly unlikely to me that the problem lies in Java. All the suggestions you've been given so far are good; but I should tell you that I've seen similar delays from a simple DNS failure, so don't go rushing to blame the database until you're pretty sure it's the problem.

And as for free: what's going to cost more, several hours of your time (possibly repetitive) or buying the product? If this is a work problem, ask the same question of your manager; and if this is "home-brew", I guess that would be you.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: what's the reason for poor performance
 
Similar Threads
synchronized block in JSP tag
Java Testing Patterns by Jon Thomas, Matthew Young
Download Optimization with JBoss 4
Host Monitoring Solutions ?
Steps to make a J2EE project LIVE on internet