The Artima Developer Community
Sponsored Link

Java Buzz Forum
7 tips to improve Server Side Java Performance

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Goldy Lukka

Posts: 1008
Nickname: xyling
Registered: Jan, 2004

Goldy Lukka is a Java Developer and an Entrepreneur. He is Founder of xyling.com.
7 tips to improve Server Side Java Performance Posted: Jan 19, 2004 3:15 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Goldy Lukka.
Original Post: 7 tips to improve Server Side Java Performance
Feed Title: Xyling Java Blogs
Feed URL: http://javablogs.xyling.com/thisWeek.rss
Feed Description: Your one stop source for Java Related Resources. These feeds are filtered, categorized and maintained by us to help ourselvs and the people around Java Community. We are continuously exploring and improving our blogs and would love to see your feedback at feedback@xyling.com
Latest Java Buzz Posts
Latest Java Buzz Posts by Goldy Lukka
Latest Posts From Xyling Java Blogs

Advertisement
I found these 7 tips from one of the newsletters of javaperformancetuning.com and loved to blog here. These tips are authored by Jayson Falkner. He has also authored "Servlets and JSP the J2EE Web Tier" Book. http://www.jspbook.com


#1 Database Connection Pooling - This is a well-established technique. Instead of opening a new database connection each time a query is done, a pool of several connections is shared. Tomcat provides fantastic built-in support for this via the Jakarta Commons Database Connection Pool API, http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html.

#2 Don't read flat files from the hard disk. Reading information from the hard drive is really slow. In the JSP world there is a trivial fix to this. We save content as a JSP page, properly translated and encoded in any language. Tomcat automatically converts the JSP to a in-memory servlet the first time someone tries to view the page's content. Any dynamic information the page relies on, say links to pages describing the day's news, is passed around using the popular Model 2 design pattern. The result is that flat files are rarely ever read more than once from the hard drive.

#3 Server-Side Caching. A servlet filter that automatically caches content for you is trivial to deploy, and it can save enormous amounts of time. Here is a full writeup I did on this, http://www.onjava.com/pub/a/onjava/2003/11/19/filters.html.

#4 Client-Side Caching. Set the HTTP response headers (i.e. Control-Cache) that tell a client what it can cache. That way users aren't downloading your header/footer images, style sheets, or javascript files multiple times. Here is a write up I did for this, http://www.jspbook.com/faq.jsp#1069699404218.

#5 Simplify everything. This is a trick taken from Google, but that some sites can't use. The technique is to trim down your content to the smallest amount of stuff you actually need. Ditch flashly DHTML in favor of plainly describing the content. Style things well using an external CSS file, don't embed styles. This results in your sever needing to send less information to a client, thus faster page download times.

#6 GZIP compress when possible. Most web browsers will accept GZIP compressed content (about 1/6th the size of normal content). Compress whenever possible and you will have to send less bytes to a user to convey the same information. Here is a writeup I did on this, http://www.onjava.com/pub/a/onjava/2003/11/19/filters.html.

#7 Know what you are keeping in memory. Far too often I've seen nicely optimized sites crash because someone is abusing either the session or application scopes. Java can have memory leak(ish) stuff. You can't reference a billion objects and expect your JVM to handle it. Whenever you can, use only the request scope for passing objects between resources in your web application. If you must use application or session scope, ensure you eventually clean up the resource.

[Resource-Type: Tip, Category: Java/JSP, Java-Edition: J2EE, Level: Intermediate/Advanced, XRating: 4]

Read: 7 tips to improve Server Side Java Performance

Topic: Ward Cunningham on dealing with new requirements Previous Topic   Next Topic Topic: SteveTV

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use