Is the server-side PHP script asynchronous?

If the PHP script is invoked by the server through the command line (on the Ubuntu server), is it possible to run multiple instances of this script at the same time? In my case, this is a PHP script that converts the downloaded video using FFmpeg. So, if eight users upload a video at the same time (or very close to it), will eight instances of this PHP script be executed or will they be queued one after another? If they are queued, is there a way to change it so that multiple instances can work simultaneously?

+4
source share
1 answer

Multiple instances of the same script can work simultaneously. It should be noted that performance will degrade scripting at the same time. You should also note that if you interact with the database and the LOCKtable for writing, this cannot be done asynchronously and will cause the queue to be formed (albeit insignificant, depending on the operations performed).

Proof

You can verify this by creating a PHP script that calls exec()somewhere inside and executes another PHP script (or indeed the same one), but be careful not to create an infinite loop). Perhaps drop a timestamp into a file or database so that you can adequately see how this happens.

+5
source

Source: https://habr.com/ru/post/1606188/


All Articles