BLOG POSTS
    MangoHost Blog / Configure Tuned and cpufreq for Server Performance Optimization
Configure Tuned and cpufreq for Server Performance Optimization

Configure Tuned and cpufreq for Server Performance Optimization

What’s This All About?

Ever fired up a brand new VPS, dedicated server, or bare metal box, only to find it’s not performing quite like you imagined? Maybe you’re running a game server, a blazing-fast CI pipeline, or a beefy database, and things just feel…sluggish.
This guide is for you.

Today, we’re diving deep into Tuned and cpufreqβ€”two powerful tools that, when combined, can squeeze every last drop of performance from your Linux server. Whether you’re a coder, a DevOps pro, or just someone who likes their servers running at full speed, I’ll walk you through what they do, how they work, why they matter, and (most importantly) how to set them up in minutes.

A Real-World Drama: Why Server Performance Optimization Matters

Picture this: It’s 2:30 AM. Your team’s app starts lagging. Deployments crawl. Users are grumbling on Discord, and the boss wants answers yesterday. You check top and see CPUs chilling at 1.2 GHz when you’re paying for 3.7 GHz turbo. Watts are saved, but so is your productivityβ€”in the worst way possible.

The culprit? Power-saving defaults and suboptimal performance profiles. Your server’s CPUs are napping when they should be sprinting. That’s where Tuned and cpufreq come in: they let you control your performance destiny.

The Problem with Default Server Performance

  • Most distros ship with conservative performance settings.
  • On-cloud, VPS, and even dedicated servers, governors (the code that sets CPU speed) are set to “powersave” or “ondemand”.
  • Great for laptops, terrible for production workloads needing instant response.
  • You’re not getting what you pay forβ€”especially if you’re renting high-end CPUs!

Bottom line: If you haven’t tuned your server, it’s probably running in Grandpa Mode (slow and careful). Let’s fix that.

How Do Tuned and cpufreq Work? (And Why Should You Care?)

What Is cpufreq?

cpufreq is the kernel-level subsystem that decides what frequency (GHz) your CPU cores run at. It uses governorsβ€”think of them as CPU mood managers. The main ones:

  • performance: Always max clocks. YOLO mode.
  • powersave: Lowest clocks. Zen garden.
  • ondemand: Ramps up when busy, down when bored.
  • conservative: Like ondemand, but even lazier to ramp up.
  • schedutil: Smarter, integrates with Linux CPU scheduler.

What Is Tuned?

Tuned is a daemon (background service) that applies pre-built or custom system profiles for dynamic, holistic performance tuning. It’s like cpufreq on steroids: it can change CPU governors, tweak kernel parameters, tune disks, network, and moreβ€”on the fly, or on demand.

  • Comes with profiles for virtual guests, servers, desktops, latency-sensitive apps, and more.
  • Can auto-detect workloads and apply best settings.
  • Easy to switch back if you break things!

How Do They Work Together?

Tuned can manage cpufreq governors, but you can also set cpufreq manually for total control. Use both for best results.

Tree of Use Cases and Benefits

  • Game Servers: Lower latency, smoother tick rate, no CPU downclocking in the middle of a raid.
  • CI/CD & Build Machines: Compile code at warp speed. No more waiting for CPUs to β€œwake up.”
  • Database & Web Servers: Handle more queries per second, less lag during traffic spikes.
  • Virtualization Hosts: Ensure all guests get fair, fast CPU time. No random throttling.
  • Scientific Computing / AI: Keep CPUs and RAM running hot for heavy crunching.
  • Desktop Power Users: Perfect for Linux workstations where you want performance over battery life.

Bonus: Want to run a VPS or dedicated box at maximum performance? Order a VPS or dedicated server and try these tweaks from day one!

Step-By-Step Guide: Fast Setup for Tuned and cpufreq

1. Check Your Current CPU Governor

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  

If you see “powersave” or “ondemand”, you’re leaving performance on the table.

2. Install Tuned and cpufrequtils

  • On Debian/Ubuntu:
    sudo apt update
    sudo apt install tuned cpufrequtils
          
  • On CentOS/RHEL/Fedora:
    sudo dnf install tuned
    sudo dnf install cpupower
          

3. List Available Tuned Profiles

sudo tuned-adm list
  

You’ll see profiles like balanced, throughput-performance, latency-performance, virtual-guest, etc.

4. Apply a Performance Profile

For max speed on servers, try:

sudo tuned-adm profile throughput-performance
  

For ultra-low latency:

sudo tuned-adm profile latency-performance
  

For VMs:

sudo tuned-adm profile virtual-guest
  

5. Set CPU Governor Manually (Optional, but Fun)

  • Show available governors:
    cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
          
  • Set to performance:
    sudo cpufreq-set -r -g performance
          

    Or, with cpupower:

    sudo cpupower frequency-set -g performance
          
  • Confirm:
    cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
          

6. Make It Stick After Reboot

  • Edit /etc/default/cpufrequtils and set GOVERNOR="performance"
  • Or rely on Tuned to keep things set at boot.

7. Restart Services

sudo systemctl restart tuned
sudo systemctl restart cpufrequtils
  

Boom! You’re running at full throttle.

Mini Glossary: Real-Talk Definitions

  • Governor: The β€œmood” of your CPU (lazy, hyper, balanced, or zen).
  • Tuned: The performance DJ mixing your kernel knobs for max beats.
  • Profile: A set of tuning rules (think: β€œgaming mode” for your server).
  • Daemon: A silent process that keeps your tweaks running in the background.
  • cpufreq: The kernel’s frequency/voltage control module for CPUs.
  • cpufrequtils/cpupower: Command-line tools to talk directly to cpufreq.

Examples, Cases, and a Comic Metaphor

Let’s meet our cast of characters:

Server Persona Governor How They Act
Speedy Gonzales 🏎️ performance Always runs at max speed, no sleep, loud and proud.
Sleepy Joe 😴 powersave Only wakes up when absolutely needed, saves energy but slow to react.
Goldilocks 🐻 ondemand Picks β€œjust right” speed, but slow to kick into high gear under load.
Zen Master 🧘 conservative Even more cautious, never gets excited, avoids spikes.
AI Overlord πŸ€– schedutil Lets the Linux scheduler decide, usually smart but sometimes unpredictable.
  • Example 1 (Winner): A CI build server running latency-performance cuts compile times by 20%. Devs happy, coffee consumption down.
  • Example 2 (Loser): Game server left on powersave. 300ms lag spikes during boss fights. Ragequits ensue.
  • Example 3 (Risky): Laptop set to performanceβ€”battery melts, but frames in Minecraft are glorious.

Beginner Mistakes, Myths, and Similar Tools

  • Mistake: Setting the governor only for CPU0. You need -r for all CPUs!
  • Myth: β€œTuned is only for RHEL.” Nope, it works on most distros.
  • Mistake: Forgetting to enable or restart tuned after changing the profile.
  • Myth: β€œcpufreq tweaks don’t matter on cloud.” Often, they doβ€”especially on dedicated cores or high-performance VPSes.
  • Similar Tools: cpupower (newer), cpufrequtils (classic); powertop (for laptops/desktops); auto-cpufreq (auto-tuning for laptops).

Use This If… (Decision Tree!)

                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚   Is this a  β”‚
                β”‚  server?     β”‚
                β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
       Yes β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Need max    β”‚
β”‚  performance?β”‚
β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚
     Yes
      β”‚
      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Use Tuned +  β”‚
β”‚ set governor β”‚
β”‚ to           β”‚
β”‚ performance  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚
      β”‚
No β”€β”€β”€β”˜
      β”‚
      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Use balanced β”‚
β”‚ or ondemand  β”‚
β”‚ for power    β”‚
β”‚ savings      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  

Still not sure? If your workloads are spiky, try ondemand or schedutil. If you want raw speed, go performance with Tuned. If you’re running a laptop or desktop, stick with the default unless you love fans.

Bonus: Want to test on a VPS or dedicated server first? Spin one up and break things safely!

Automation, Scripting, and Fun Facts

  • Script Example: Auto-set performance governor at boot:
    #!/bin/sh
    for CPUF in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
      echo performance | sudo tee $CPUF
    done
          

    Put this in /etc/rc.local or as a systemd service for auto-apply.

  • Tuned can be triggered by udev rules or scripts (e.g. switch profiles when a certain app starts).
  • Combine with monitoring! Use htop, lscpu, or watch -n1 "cat /proc/cpuinfo | grep MHz" to see changes live.
  • Weird Fact: Some cloud providers throttle β€œidle” VMs even with performance governorβ€”check with support if you’re not seeing results!

New opportunities: With proper tuning, you can automate load-based profile switching, optimize for different workloads (batch jobs vs. real-time processing), and even save on your energy bill if you’re running a home lab.

A Short, Fictionalized Admin Story

Meet Alex, a sysadmin who just migrated a bustling web app to a beefy new dedicated box. Users expected blazing speed, but traffic spikes made the site feel…meh.
Running cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor, Alex found β€œondemand” everywhere. A quick sudo tuned-adm profile throughput-performance and sudo cpufreq-set -r -g performance later, and boomβ€”response times dropped by 35%, and the team’s Slack channel exploded in celebratory memes.

Moral: Don’t let defaults slow you down. Take the wheel!

Conclusion & Recommendations

  • Why: Out of the box, most servers run in power-saving mode. If you care about speed, you gotta tune it.
  • How: Use Tuned for system-wide profiles and cpufreq for direct CPU control. It’s fast, reversible, and gets results.
  • Where: On any Linux serverβ€”cloud, VPS, dedicated, or even your dev box.
  • Who: Anyone who wants to stop wasting CPU cycles and get the performance they paid for.
  • When: Right now, before your next big deploy, game night, or migration!

Ready to unleash your server’s true power? Try these tweaks today, and if you’re shopping for a high-performance VPS or dedicated box, order one at MangoHost VPS or MangoHost Dedicatedβ€”then show your CPUs who’s boss!

Got questions, scripts, or weird results? Drop them in the comments or DM your favorite admin nerd. Happy tuning!



This article incorporates information and material from various online sources. We acknowledge and appreciate the work of all original authors, publishers, and websites. While every effort has been made to appropriately credit the source material, any unintentional oversight or omission does not constitute a copyright infringement. All trademarks, logos, and images mentioned are the property of their respective owners. If you believe that any content used in this article infringes upon your copyright, please contact us immediately for review and prompt action.

This article is intended for informational and educational purposes only and does not infringe on the rights of the copyright owners. If any copyrighted material has been used without proper credit or in violation of copyright laws, it is unintentional and we will rectify it promptly upon notification. Please note that the republishing, redistribution, or reproduction of part or all of the contents in any form is prohibited without express written permission from the author and website owner. For permissions or further inquiries, please contact us.

Leave a reply

Your email address will not be published. Required fields are marked