Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a php script multiple times

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

I'm building a mySQL table from a series of large files ranging anywhere from 100 megs to 2 gigs. On average, there will be around 150,000 records in the table.

I'm doing so right now by having a javascript function that does an AJAX call to the PHP script. On success, the function sets a timeout to run itself and trigger the AJAX call to run the second hundred.

My thinking behind this was to give the function a second to close out before it runs itself again.

This isn't working so well. The whole function itself works, but performance-wise it is quite slow.

When I wasn't doing 100 records at a time and not wasn't using javascript, just PHP, I could get about 15,000 records into the table before it would time out. Right now it takes about 10 minutes for it to do the same number of records.

I know that the continuous running javascript is bleeding memory and performance like crazy and was just wondering if anyone had any ideas on how to accomplish running a PHP script over and over from a browser. Crons are not an option at this point.

like image 666
Eric Strom Avatar asked Jun 15 '26 05:06

Eric Strom


1 Answers

Its called (async) work/job queues, seems you need to explore Gearman

like image 59
Artjom Kurapov Avatar answered Jun 16 '26 19:06

Artjom Kurapov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!