Sunny D'Souza
Sunny D'Souza

Reputation: 626

Prevent time/memory intensive php script from crashing/slowing continuously

I have a php script that exports out results in excel using PHPExcel plugin. Now since the result has around 40 columns and above 15k+ rows, it seems to be taking a lot of time, which isnt a problem for me.

However what I find is that the apache server(of my WAMPserver installation) keeps crashing after certain intervals and it also slows down my machine (the script runs local to my machine).

There are 2 things I need help here 1) Stop apache server from crashing down 2) prevent PC from slowing down

I have set_time_limit(0);ini_set('memory_limit', '-1'); in my code so I have removed the restriction of the script timing out and also the memory limit imposed.

Time to export is not a factor for me...If it takes 20 mins+ to export out the result in excel also, it should be fine (though i would prefer if there is a faster alternative ;) ). Just that the script should execute without slowing my machine (so I can multitask) and apache shouldnt keep crashing

Upvotes: 1

Views: 589

Answers (1)

Yousf
Yousf

Reputation: 3997

Here are some tips which might help:

  1. Don't use Apache. Use PHP Command line interface.
  2. Compile the PHP script to an executable for faster execution.
  3. Lower the priority of Apache (or command line ) process.
  4. Consider converting the script to faster (or more stable) language (Java, C#, C++, ...)

Upvotes: 2

Related Questions