tags:

views:

62

answers:

3

My application loads a xml and update xml elements for each request.

I have 10 to 20 requests come at a time , the xml loading process is taking some time for each request because it is in synchronized block.

The xml size is 500 KB and used DOM parser (Legacy code).

Are there any ways to improve performance?

+1  A: 

Without knowing more about your application, other consumers of the XML data, or the control you have over your environment, you might consider keeping the data on the application server (is it the same file or a bunch of different files, each 500kb?) and running a periodic copy job to send an updated copy back to the original source at a reasonable interval.

Jay
merging might be difficult if there is more than one application server (or other writers).
Thilo
The XML resides on the same machine/server
Thomman
Okay, but to be clear, the original question DID say that the files were on a different machine. What we still haven't heard is whether we're dealing with one XML file or if all of these 20-30 simultaneous requests are working with different XML files.
Jay
A: 

I have replaced DOM parser with Stax parser. Solved my issue.

Thomman
+1  A: 

I have replaced DOM parser with Stax parser. Solved my issue.

VTD-XML is faster and memory-efficienter. However... I highly question the need to parse the XML file on every request. Caching it in application scope using a ServletContextListener and saving the cached content every minute or so using a TimerTask would be more efficient.

BalusC