Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Struts 2 & Dojo files are too heavy and affect site's performance.. Any remedies?

Well.. we've developed a j2ee application using struts2 ajax capabilities. We find that the dojo implementation is quite slow. We did the following things: 1. Custom build of the dojo library. (increased dojo.js from 240kb to 350kb) 2. Took all the static stuff out of the struts jar and kept it outside.

The performance was significantly improved. But still it is quite heavy as you can guess with 350kb size..

Is struts2 ajax supposed to be this heavy? or is there any lighter implementation available?


Edit: I used Firebug and YSlow with my application. Couple of changes that improved my situation hugely are mentioned below:

  1. Custom build of dojo (reduced the number of I/Os)
  2. Move the static files out of Struts jar (helped a great deal)
  3. tune your server to gzip the response (reduced the response size to 1/3)
  4. Reduce number of images on your site.(this is obvious)

Will keep updating on further changes..

like image 525
Satya Avatar asked Nov 29 '08 18:11

Satya


2 Answers

First of all check that you did everything on the server to facilitate caching (e.g., setting right HTTP headers, compression, server-side caching, upstream caches, and so on). See Improving performance… for more details.

The goal is to reduce I/O as much as possible — use Firebug or any other network traffic monitoring tool to see how much is sent back and forth. Try to minimize the number of I/O requests and the total number of bytes.

Don't forget that it applies to your dynamic data too — choose efficient formats, bundle several related requests together, remove all deadwood that is getting sent over and over unchanged.

If the custom build and server-side tweaks didn't help, consider restructuring your web app to be more light-weight. Examples:

  • Evaluate the splash screen technique discussed in the link above.
  • If you use a lot of different form widgets, see if it is really necessary, and fall back on regular DOM elements like "input", "button", "textarea", "select".
  • The same goes for layout widgets. See if simple CSS can help you out.
  • Evaluate building Dojo in layers instead of one monolithic dojo.js so only the necessary subset is loaded by web pages. See details in The Package System and Custom Builds.

Building web applications with Dojo for a living for last 2 years I still didn't see the one that cannot be optimized properly until it is fully accepted and perceived by end users as "fast", "nimble", and "light-weight".

like image 129
Eugene Lazutkin Avatar answered Sep 19 '22 23:09

Eugene Lazutkin


Make sure you follow this faq first: http://struts.apache.org/2.x/docs/performance-tuning.html

I usually re-write my own theme instead of using the struts2 ajax theme which has dojo built in. This way I can use whatever toolkit I want to use (jQuery). I saw the biggest performance improvements when I copied the templates folder from the jar to the root web directory for the webapp.

like image 40
Ruggs Avatar answered Sep 22 '22 23:09

Ruggs