Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what's the reason for poor performance

 
David Yin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1208
25
Android C++ Java Linux PHP Python
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 10494
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic