title: Parallel XML Parsing in Java
body: <p>I'm writing an application which processes a lot of xml files (>1000) with deep node structures. It takes about six seconds with with <a href="http://woodstox.codehaus.org/" rel="noreferrer">woodstox</a> (Event API) to parse a file with 22.000 Nodes.</p>
  
  <p>The algorithm is placed in a process with user interaction where only a few seconds response time are acceptable. So I need to improve the strategy how to handle the xml files.</p>
  
  <ol>
  <li>My process analyses the xml files (extracts only a few nodes).</li>
  <li>Extracted nodes are processed and the new result is written into a new data stream (resulting in a copy of the document with modified nodes). </li>
  </ol>
  
  <p>Now I'm thinking about a multithreaded solution (which scales better on 16 Core+ hardware). I thought about the following stategies:</p>
  
  <ol>
  <li>Creating multiple parsers and running them in parallel on the xml sources. </li>
  <li>Rewriting my parsing algorithm thread-save to use only one instance of the parser (factories, ...)</li>
  <li>Split the XML source into chunks and assign the chunks to multiple processing threads (<a href="http://www.cs.ucdavis.edu/research/tech-reports/2009/CSE-2009-12.pdf" rel="noreferrer">map-reduce xml - serial</a>)</li>
  <li>Optimizing my algorithm (better StAX parser than woodstox?) / Using a parser with build-in concurrency</li>
  </ol>
  
  <p><strong>I want to improve both, the performance overall and the "per file" performance.</strong></p>
  
  <p>Do you have experience with such problems? What is the best way to go?</p>