0

I have an AmazonEC2 instance with 4 cpus. I use it for creating PDF reports on it. The maximum number of user requests are 10 to 15 users in an hour. However, the report size is humongous, around 3000 to 5000 pages PDF files. It takes 70 minutes for FOP to render one of these report.

The issue is Java process is only using one cpu while rendering a report. Is there any way such as from configuration, I can force FOP to use more cpus then only 1?

What have I tried so far?

I have remove the logging as suggested on ApacheFOP website, also I am using page sequences in XSLT I am making sure that I have all the style tags are being reused.

Any changes I have done to FOP?

Few page-sequences are huge so that I have to give -xms 2000M to java so it does not go out of memory. Btw, The machine has 16GB RAM.

TeaCupApp
  • 11,316
  • 18
  • 70
  • 150

2 Answers2

2

Take a look at FOP's Intermediate Format. With it, you can concurrently format multiple documents. Later you can concatenate the intermediate format files to produce a single printing stream very quickly. The most costly part is the formatting. Generating the printing stream afterwards is very quick.

Jeremias Märki
  • 1,727
  • 10
  • 10
  • that is very interesting. Thanks for sharing. I will see if that solves my problem. Will remember to accept your if this does the trick. Thanks Again – TeaCupApp Aug 27 '13 at 12:24
1

Apache FOP isn't thread-safe, so it can't be used concurrently across multiple threads. Have you thought about looking for a different solution that handles multi-threading better, like JasperReports? Using JasperReports, you can split those thousands of pages into sub-reports that you run to generate the PDFs. By using sub-reports, JasperReports will automatically spawn new threads to generate them. It will require some work in iReports and some learning on your part, but for reports of this size, I highly recommend it.

Brian
  • 17,079
  • 6
  • 43
  • 66
  • Thank you for the great suggestions. It is bit tricky for me to switch to new Reporting library. But, I will sure look in into it. – TeaCupApp Aug 27 '13 at 06:24
  • @Owl It will definitely make your life way easier if you decide to switch. Using JasperReports and iReport, you can visually design your report in the iReport UI, open the design in Java code, attach data to it, then run it. Charts are available from iReport as well, but if necessary, you can always draw your own custom images directly on a `Graphics2D` object using the `Renderable` interface and its implementations. – Brian Aug 27 '13 at 06:45
  • Cool, but I have to make sure that these things has to be automated. Because, clients selects some params on web backend, and I have to prepare data from DB and then send it to Jasper(in this case). Seems like a big learning curve. Also, I don't know whether the workflow I have can be implemented with Jasper. :) – TeaCupApp Aug 27 '13 at 07:21
  • If I can create the template design export file from iReport and then feed Jasper server with my data and template stylesheet that would be great. Let me get into the doco. :) – TeaCupApp Aug 27 '13 at 07:23
  • That FOP isn't thread-safe is not true (anymore). A lot of users use FOP to produce multiple output streams concurrently. It's just that FOP isn't multi-core-friendly: it only uses one thread per document. So, similar to Brian's suggestion, you can split your reports into sub-reports and run them concurrently with FOP. – Jeremias Märki Aug 27 '13 at 09:32
  • @JeremiasMärki, Thanks for the input :). I had that idea but then realised that making sub reports will screw up the page numbers. – TeaCupApp Aug 27 '13 at 09:56