Monthly Archives: November 2014

Tuning CPU performance on Linux server

If you have an older desktop CPU for the server, like me (AMD Phenom II), you web applications may be suffering from slow page loads. Some (older) CPUs switch to the faster frequencies from power-saving mode very slowly. And this causes slow page rendering.

There are two ways to improve CPU performance on Linux sever.

One is by holding frequencies at maximum all the time. That increases power consumption.
for core in $(seq 0 3); do # Core from 0 to 3 (4 core CPU)
  if [ "`cpufreq-info -c $core | grep \\\"performance\\\"`" == "" ]; then
    cpufreq-set -c $core -g performance
The second one is to instruct the OS to scale up the frequencies on 20% load:
if [ -f $file ]; then
  if [ "`cat $file`" != "20" ]; then
    echo 20 > $file

Performance isn’t much slower and fan noise is much more ear pleasant.

Cpu-freq must be installed. Use “sudo apt-get install cpufrequtils”. Save the code into a file and run it every few minutes with the help of “cron”.

In my case the time to render a WordPress site decreased from around 800 ms to 500 ms.