Page 1 of 1

PDF performance issues

PostPosted: Tue Sep 08, 2015 2:26 am
by mailtomanu
Hi Team,

When tried to load test, a Docx4j based PDF conversion application, we observed that the application doesn't scale beyond 15 concurrent users. The scenario is that 20 concurrent requests to render a PDF from a Docx template by binding it to an XML bring down the application server with Max Heap Size set as 1024M. We are using FO-XSL for PDF conversion. The core part of the code would be looking like below :

Code: Select all
    wordMlStream = new FileInputStream(input_DOCX);
         
         WordprocessingMLPackage wordMLPackage = Docx4J.load(wordMlStream);

         // Open the xml stream
         xmlStream = new FileInputStream(new File(input_XML));
         
         Docx4J.bind(wordMLPackage, xmlStream, Docx4J.FLAG_NONE);
         FOSettings foSettings = Docx4J.createFOSettings();
         foSettings.setWmlPackage(wordMLPackage);
         os = new java.io.FileOutputStream(OUTPUT_PDF_PATH);
         Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);


Is there any possibility of optimization here?

Thanks in advance for suggestions....

Re: PDF performance issues

PostPosted: Tue Sep 08, 2015 7:29 am
by jason
You can try:

Code: Select all
Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_NONXSL);


That'll be faster and use less memory, but doesn't have feature parity with the XSL output. Nothing stopping you from adding anything you miss.

But really, for decent performance - especially under load - you should try Plutext's commercial PDF Converter. Its much faster, and uses less resources.

Re: PDF performance issues

PostPosted: Thu Sep 10, 2015 10:23 pm
by jason
Further to this, if you're doing PDF via XSL FO, a 1 GB heap may not be enough for a single large document, let alone 20 concurrent requests.

If you allocate more memory, the behaviour we expect is for it to be slow .. you don't want to be running out of memory.