开发者

Performace enhancement for a Struts2 application(website) with high traffic usage

开发者 https://www.devze.com 2023-03-14 23:17 出处:网络
I wanted to ask that what all things i should keep in mind in order to create a high performance STRUTS2 based web application. It is guaranteed that the site will have a high traffic (i.e. lets assum

I wanted to ask that what all things i should keep in mind in order to create a high performance STRUTS2 based web application. It is guaranteed that the site will have a high traffic (i.e. lets assume somewhere around 500,000 requests daily). Also there will be a decent lot of database accesses.

Please comment as i have decided of using the following frameworks (or开发者_开发问答 suggest any better alternatives):

  1. Struts2 + springs and hibernate
  2. Jsp + jquery for views
  3. DWR for ajax calls

Please suggest some performance tuning/enhancement strategies. Thanks!


Couple of things you can do.

First:

the biggest bottleneck in a website is always the database connection. You will need to make sure that your database is running in a separate cluster and try to do more in each database session when using hibernate. The less DB connections you open/close the faster your application will be.

Use hibernate as much as possible because it has logic to cache queries and such. Also if you have the same information being used across the users session, put it on the session object so that you do not have to query the DB for that info multiple times.

Second:

Use the Spring IOC as much as possible. You should create "service" classes that will be doing your database querying and those classes should be created as singletons and injected into a constructor or setter via Spring IOC.

Third:

Make use of a tool like tiles or wicket. It will allow you to create layouts for your JSPs.

Fourth:

If you have data displaying on the page that takes a long time to load/query, go ahead and load the page with the other data that is fast and then load your slow data dynamically through AJAX. It will give the user the impression that they are receiving an immediate result.

Of course there are many other things you can on the server side. You might want to deploy the application across several node and use a load balancer to route traffic to the least busy node. The amount of caching at the proxy, app server, browser, and database you do will also significantly impact your performance.

Hope that helps!


Since you are using hibernate, you should also look into hibernate performance tuning for which there are lots of resources including these discussions:

  • https://stackoverflow.com/questions/2460342/books-and-resources-for-java-performance-tuning-when-working-with-databases-hu/2460466#2460466
  • Hibernate performance
  • Hibernate performance
  • Usual hibernate performance pitfall


  1. Avoid bottlenecks in your app design - see these tips from Yahoo.
  2. Run the web server, application server and database server on seperate hardware clusters.
  3. If the performance isn't good enough profile to see what is slowing it down; if there is a bottleneck in the code fix it, otherwise add hardware until it is fast enough.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号