Isabel Jinson
Isabel Jinson

Reputation: 8661

Load XML for each request

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?

Upvotes: 1

Views: 287

Answers (3)

BalusC
BalusC

Reputation: 1108742

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.

Upvotes: 1

Isabel Jinson
Isabel Jinson

Reputation: 8661

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

Upvotes: 0

Jay
Jay

Reputation: 57939

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.

Upvotes: 1

Related Questions