I have a VPS. If you simultaneously trigger processing of several video files, then ffmpeg eventually eats up all the resources and scripts (PHP, MySQL) are very slow! It happens and "exceeded the waiting limit" at some point.

I understand that you can take a more powerful server and the problems will go away. The question is whether it is possible to limit CPU consumption from ffmpeg no more than 50% with a single core on a VPS. Roughly speaking, indicate to the application (ffmpeg or another) the maximum allowable limits?

Or if there are 2 cores (2 core) VPS configured so that ffmpeg works only on one core, and nginx + php-fpm + mysql on the second?

I’ll clarify, I don’t mind that the videos were processed 2-3 times longer through ffmpeg, so long as the site worked steadily.

Thank.

    1 answer 1

    You can use the nice program. instead:

    $ программа аргументы 

    run:

     $ nice программа аргументы 

    this will affect the task scheduler: processes with a higher “niceness” value will get fewer processor cycles than those with lower niceness. user processes usually get a “niceness” of 0.

    the minimum value of “niceness” is -20 (the highest priority of the process), the maximum is 19 (the lowest priority).

    using the -n число option, you can specify the value that should be added to the current value of “niceness” (it is inherited by child processes from the parent). if not specified, 10 is added.

    You can see the “niceness” of processes, for example, in the output of the top program ( NI column), or in the output of the ps program, like this:

     $ ps -eo pid,user,args,nice --sort nice 

    using the renice program, you can change the “niceness” of an already running process.


    additional reading:

     $ man nice $ man renice