Your server is more complex than the most fiendishly intricate mechanical device ever devised. It depends on dozens of pieces of software and tens of millions of lines of code, not to mention the hardware, which is mind-bogglingly complicated. All of those pieces work together to serve your web pages and run your shopping carts. As you can imagine, there are hundreds of ways to tweak the way the parts interact, and many of those tweaks impact performance.
There is no such thing as a server that is perfectly optimized for performance in every scenario. A server running a number-crunching financial application uses the server’s resources differently to a database. Some applications have a thirst for CPU power and some gobble up data as fast as it can be lifted from the SSD, only to send it on its way with barely any processing. Some applications require the network to churn out hundreds of megabytes every minute without pause for months on end, and some merely tickle the ethernet interface every few minutes.
Performance optimization is all about tradeoffs between power consumption and memory, processor, disk, and network performance. Tuned is a utility that can help server hosting clients to flick many of the switches that impact performance in one swipe, according to the needs of their application. It provides several performance profiles for clients to choose from, each of which makes changes that optimize a server for specific scenarios.
If you’re running CentOS 7, Tuned is already installed and active. CentOS 6 users will have to install it with this command.
yum install tuned
To run the daemon, use systemctl.
systemctl start tuned
Tuned can be used to dynamically adjust performance on the fly by monitoring CPU, disk, and network use and applying optimizations accordingly, but I’m going to focus on manually selecting profiles.
Tuned profiles are designed to balance power saving with the needs of the server. When it is first installed Tuned activates the “balanced” profile, which is fine for everyday performance but it may not be ideal for your scenario.
To interact with Tuned, we use the tuned-adm command. You can see which profile is active on your server with this command.
You can also view the list of installed profiles.
In the list, you will see profiles such as throughput-performance and network-latency. Each profile changes numerous configuration options that impact the performance of the server. The throughput-latency profile, as the name suggests, configures the server for optimal data throughput by disabling power saving mechanisms and enabling sysctl settings to improve the throughput performance of the disk and network, switching to the deadline scheduler and setting the CPU governor to performance.
For general server workloads, throughput-performance is often the best option and is likely to result in better performance than the default balanced profile.
You can change the performance profile used on your server with:
tuned-adm profile *a-profile-from-the-list*
You aren’t limited to the profiles included with Tuned. It’s possible to create custom profiles. The Red Hat documentation covers custom Tuned profiles in depth.
We’ll end on a note of caution. Performance optimization is all about tradeoffs and choosing the right combination of settings for your specific use case. It’s a good idea to monitor the performance of your server before and after any configuration changes to ensure that they don’t make performance worse instead of better.