Consider starting a separate process on a server that will run continuously, receive working units from PHP scripts, execute them, and return the results. PHP script, and this process can use the database to exchange work units, so when PHP has some work, it inserts the job description into the database. When a separate process is ready for work, it queries the database for pending work units, marks them in the database during processing. Later, processing is performed, it marks the work block in the database as completed and attaches the result of processing to it.
source share