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.
#!/bin/bash
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
  fi
done
The second one is to instruct the OS to scale up the frequencies on 20% load:
#!/bin/bash
file=/sys/devices/system/cpu/cpufreq/ondemand/up_threshold
if [ -f $file ]; then
  if [ "`cat $file`" != "20" ]; then
    echo 20 > $file
  fi
fi

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.

Leave a Comment





NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>