Mar 14, 2015 at 1:53 AM
Edited Mar 14, 2015 at 2:36 AM
I am using PHPExcel to generate large report files for customer orders. The script reads a CSV, inserts them into a database, then re-reads them, does the calculation and then writes the data row by row to a xlsx-file. We talk about 5000 to 7000 rows. The rows
are inserted in a for-loop, which loops over all countries customers ordered from.
Doing this sometimes
works on my local apache, but running the script on production server causes a "504 Gateway Timeout", after about 10 minutes of loading.
I "managed" to crash my local apache to get some information with xdebug:
The following images are from a run where the script terminated:
And the number of calls:
(What is hidden in this pic: the save-function takes about 46% usage)
As you can see, I call getActiveSheet() very often, because I write data to two different sheets at the same time. I do
do calculations or formulas with PHPExcel, this is done in the script, and PHPExcel writes only plain numbers. After writing all rows, I do some formatting (column width, font, font size, table grids usw.).
I am using the latest version of PHPExcel, 1.8.0.
Specs on the machines I tested the script on (with crashes)
- my local computer: Apache 2.4.9 with PHP 5.4.27 on Windows 8.1
- production server 1: Apache 2.4.7 with PHP 5.5.9 on Ubuntu
- production server 2: Apache ??? with PHP 5.3.3 on Linux (phpinfo() doesn't provide any more information..)