1

I'm developing a web application, and using a typical lamp stack. I'm using dompdf to generate some reports to pdf. In one case, I have a simple table list (think list of clients) with some simple info (name, phone number, email, etc...) but the user has close to 400 clients in this list. When trying to render the report to pdf, the Allowed memory size is exceeded and an error occurs. My question is how do I approach a solution to this? If one user running a report is eating all my cpu, I can only imagine this when 100's are users try and run reports at the same time on the production server (rackspace cloud server)

The exact error is:

[Wed Apr 24 01:06:54 2013] [error] [client 127.0.0.1] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 83 bytes) in /home/redacted/redacted/v2/application/libraries/dompdf/include/style.cls.php on line 863, referer: http://redacted.v2/reports

Do I need to spawn a separate process for each report run? I'm not exactly sure how that's done (I guess I would need to do this via PHP). Basically I don't want my server to come to a screeching halt any time a large report gets run. Any thoughts or advice is much appreciated!

1 Answer 1

2

You could run a separate process which handles all reports, this way only one process would need to take up resources instead of many. Especially in a multi user environment this would be a good idea. Yes, you can run processes from php, check the documentation for e.g. popen().

On the other hand, it should also come to mind to think whether this (dompdf with php) is the best way to go concerning large reports. There are also other implementations of pdf-creating services running faster and more efficient with resources.

EDIT: For a quick fix for your current error, you could stretch up PHP's memory limit to e.g. 256M, but this would only be a workaround, instead of a real solution.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .