PHP-FPM on Linux, SCHED_BATCH or SCHED_OTHER?

pepoluan asked:

I have a Linux webserver (Ubuntu 12.04, kernel 3.2.0) running Magento with quite a number of PHP-FPM child processes.

Since Magento is a heavy framework, I often see several child processes to baloon in CPU% (when viewed using htop) for several seconds before dropping out of the top N.

I have been reading about Linux CPU schedulers, and what I got was that SCHED_BATCH seems to give longer timeslices to processes than the default SCHED_OTHER.

Would it be beneficial if I change the schedulers for all PHP-FPM processes to SCHED_BATCH? Or am I misunderstanding the schedulers?

My answer:


After learning a little about SCHED_BATCH, I wouldn’t even attempt to benchmark it:

SCHED_BATCH also triggers much longer, batch-like
timeslices – the default SCHED_BATCH timeslice is 1.5 seconds.

SCHED_BATCH was clearly designed for very long running (hours or even days) compute-intensive jobs. Your jobs are only compute-intensive for seconds or fractions of seconds.

This pretty much makes it a no-go for a web server. And it would be worse if the database is on the same machine, as they might contend for one of those extra-long timeslices.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.