This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Performance and the fly likes Performance Tuning Java Web Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Performance Tuning Java Web Application" Watch "Performance Tuning Java Web Application" New topic
Author

Performance Tuning Java Web Application

sushil bharwani
Greenhorn

Joined: Mar 02, 2006
Posts: 26
I have a java web application and i m facing performance issues; i need to optimize my code to do it ; can somebody suggest me what all things i should keep in my mind or areas i should look for ; also i want to know that a lot of time is consumed in downloading js css images files and header footer files ; cannot this be optimized or kept in browser or some other cache
Balasubramanian Chandrasekaran
Ranch Hand

Joined: Nov 28, 2007
Posts: 215

Originally posted by sushil bharwani:
I have a java web application and i m facing performance issues; i need to optimize my code to do it ; can somebody suggest me what all things i should keep in my mind or areas i should look for ; also i want to know that a lot of time is consumed in downloading js css images files and header footer files ; cannot this be optimized or kept in browser or some other cache


One way is by setting the objects which you are not using to be "null".Which can boost a bit of performance for your application.
If you are more concerned about Performance and want to implement cache solution then you can look for Java Caching System(JCS) which is a jakarta project.
JCS LINK
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41125
    
  45
One way is by setting the objects which you are not using to be "null".

This is a micro-optimization, which may or may not do anything, and may actually be harmful with modern-day JVMs.

Make sure you actually need to optimize, and that you measure what you're tuning before and after you do it, so that you can be sure that your changes have the desired effect. Further hints can be found in the http://faq.javaranch.com/java/PerformanceFaq.


Ping & DNS - my free Android networking tools app
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
JAMON is easy to install and would be a good starting place to decide where your problems lie.

Many times people are surprised by the actual location of the performance problem.

For an amusing walk thru computer science history do a google search for:
"premature optimization is the root of all evil"

Bill
sushil bharwani
Greenhorn

Joined: Mar 02, 2006
Posts: 26
I tried a lot to improve on performance on a piece of code but am not able to find out where the exact bottle neck lies what ever i try whatsoever i do i am stuck and feel hopeless does there exists any tool which can tell me where i can find which line of code or which method is most expensive
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41125
    
  45
Did you follow Bill's advice and installed and used Jamon?
vishalraju shah
Greenhorn

Joined: Oct 06, 2007
Posts: 19
It seems you need some profiling tool to drill down into your application. I have worked little bit with JProfiler which is good tool (unfortunately it's licence copy), profiling tools gives you good summary where your objects are heavily created ,how many times method are called , execution time and lot others.

Java application monitor seems good , worth monitoring your application with that.

Also , if you want to you use caching than JCS or EHcache(for object caching) are good option.


SCJP1.4 (92%), SCWCD (85%), SCBCD (81%), SCEA-I (In Progress)
sushil bharwani
Greenhorn

Joined: Mar 02, 2006
Posts: 26
Actually the issue is i use Broadvision applicatioon Server installed on a Remote Server which os Solaris Machine and its becomes quite difficult for me configuring any profiling tool on that server I am finding myself in a helpless mode
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
If you can't monitor the real running application, can you create a local version on your own system and simulate a load on it?

Bill
sushil bharwani
Greenhorn

Joined: Mar 02, 2006
Posts: 26
Well No i cannot do it;After moving much within the code i found that its a jsp which is taking most of the time inside the JSP there is a menu.jsp file included which if not included makes my file work faster. the menu.jsp file has a lot of div tags and javascript which takes somewhere around 10 seconds to render on browswer.So my question is cannot in someway i can use my broswer cache to cache this entire menu and thus save time.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
So my question is cannot in someway i can use my broswer cache to cache this entire menu and thus save time.


It sounds like you have been doing some excellent detective work to locate the source of your problem.

If the menu created by menu.jsp does not change (too much) between requests, you may be looking at an excellent opportunity to use AJAX style dynamic programming. This would leave most of the page built on the browser intact while refreshing only the data that changes between requests.

AJAX is a very hot topic so you can find plenty of resources. You might start at the HTML and Javascript forum here at the ranch.

Bill
[ January 08, 2008: Message edited by: William Brogden ]
Raees Uzhunnan
Ranch Hand

Joined: Aug 15, 2002
Posts: 126
Check about "data islands". This might help you in your effort isn storing temporary static data at the browser side


Sun Certified Enterprise Architect
Java Technology Blog
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 860
Before spending too much time on caching on the browser side I would ensure the performance issues are caused by the html/javascript and not the jsp itself. Based on your write up the source of the performance problem is not conclusive to me.


An easy test to see if it is javascript/html that is the performance problem is to do a save-as from your browser and load the saved static html. If that is slow (the 10 seconds you mention) then you have a client side problem. Based on the 10 second figure I am guessing your problem is more likely to be serverside.

Using the jamon servlet filter you should be able to get server side page timings. This can be done on your development server if you don't have access to your prod server. The servlet filter will give you performance numbers for all of your web pages including jsp's. If menu.jsp is slow (i.e. the 10 seconds you mention) then this is a server side problem and you will need to tune your java code. The jamon servlet filter requires no code changes to work, so it is quite easy to do.


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Performance Tuning Java Web Application
 
Similar Threads
which tools should i use to perform a load test on my Struts application ?
How much can a database bare?
Confusion Regarding where to put jsp in Web-application.
application page shows blanks upgrading from Tomcat5.5 to tomcat 6
session data lost when update new java files