Monday, April 29, 2024
13
rated 0 times [  13] [ 0]  / answers: 1 / hits: 3070  / 1 Year ago, fri, december 2, 2022, 8:34:39

I'm writing a very simple browser based MP3 player in PHP. Part of this project requires that every MP3 file is converted to a WAV file. There's a function in PHP called shell_exec that allows you to execute a command via the shell. For my project, whenever someone uploads a song to their account, the following command would be executed:



shell_exec('ffmpeg -i inputSong.mp3 outputSong.wav')


So let's say there are 10 different people who finish uploading a song at the same exact time. Does the Linux server execute 10 shell commands simultaneously or does it only do one at a time?



If a server can handle multiple shell commands simultaneously, would the server be able to handle converting 10 different songs at the same time or does it only do one at a time?


More From » command-line

 Answers
4

If you are doing it via PHP (or any other language that has access to shell commands) they will be done separately, which means that they will be done simultaneous if by chance the 10 users use the PHP script at the same time. Each PHP call through shell_exec will be done independent of the others. I myself have a shell_exec script which shows some information to my users for certain images and this is done independently from other PHP executed scripts through shell_exec.



There is a limit to how many simultaneous users PHP can handle, but it depends on your web server, PHP configuration file and MySQL if you are using it. I know the number is greater than 100 at the same time.



When using CPU intensive commands, for example converting videos, the effective use of the commands would then depend on how much RAM you have and how much CPU power you have. For someone with 64 MB RAM and a 80486 it would go bad to try to convert two videos and 10 songs. That would overload the system. For someone with a Core 2 Duo server and 4 GB RAM I think converting several songs would be a piece of cake.



So basically, yes, Linux can handle multiple simultaneous shell commands, specially from PHP, but the overall performance would depend on the resources of the server (CPU, RAM, hard disk drive, etc.)


[#43703] Friday, December 2, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rialhirt

Total Points: 422
Total Questions: 113
Total Answers: 120

Location: France
Member since Sun, May 15, 2022
2 Years ago
rialhirt questions
Mon, May 24, 21, 18:24, 3 Years ago
Tue, May 10, 22, 21:43, 2 Years ago
Thu, Feb 16, 23, 16:32, 1 Year ago
Mon, Jun 13, 22, 03:02, 2 Years ago
;