Run PHP script multiple times

I am looking for a way to run a php script multiple times from a browser. Here's the script:

I am building mySQL table from a series of large files ranging in size from 100 megabytes to 2 gigs. On average, the table will have about 150,000 records.

I am doing this right now, having a javascript function that makes an AJAX call to a PHP script. On success, the function sets a timeout to start and triggers an AJAX call to start the second hundred.

My thinking with this was to give the function a second to shut it down before it starts up again.

It doesn't work that well. The whole function itself works, but it is rather slow in performance.

When I wasn't doing 100 records at a time and using javascript, just PHP, I could get about 15,000 records in the table before it shuts down. It now takes about 10 minutes to make the same number of entries.

I know that javascript running continuously is dumping memory and performance like crazy and was just wondering if anyone has any ideas on how to execute PHP script over and over again from the browser. Crowns are not currently an option.


source to share

4 answers

Its callable (async) work / task queues, it seems you need to look into Gearman



Could you just repeat the PHP script function multiple times? If the problem is that the function sometimes fails or times out, could you catch the exception in your script? Or do you have an inevitable and completely fatal mistake that really requires the use of an external device?



I ran into a similar situation ... my solution was to use an ajax queue. Basically, you are submitting a series of ajax calls to a queue that fires them sequentially, starting with the next one after the previous one returns from the server as successful.

Setting a timeout can lead to a situation where the next ajax call is made before the server completes the last one. This is the likely cause of your performance issue. I don't really like javascript times by themselves, only for overuse of resources.

Google "Ajax Queue" for code you find useful, or I can post mine which is jQuery.



set up a cronjob to run the script every minute



All Articles