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 perfor开发者_如何转开发mance?
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.
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.
I have replaced DOM parser with Stax parser. Solved my issue.
精彩评论