This page contains my thoughs about everything I can explain in less than a page, mainly ideas about new companies and markets.
Monday, June 23, 2025
Support Freedium
Dear Freedium users,
We've updated our donation options to provide you with more ways to support our mission. Your contributions are invaluable in helping us maintain and improve Freedium, ensuring we can continue to provide unrestricted access to quality content.
We now offer multiple platforms for donations, including Patreon, Ko-fi, and Liberapay. Each option allows you to support us in the way that's most convenient for you.
Your support, no matter the platform or amount, makes a significant difference. It allows us to cover our operational costs and invest in enhancing Freedium's features and reliability.
Thank you for being a part of the Freedium community and for your continued support.
Choose Your Preferred Donation Platform:
11 Key Linux Performance Tuning Tricks for DevOps Engineers
improve application speed, resource usage, and system stability.
1. Optimize CPU Scheduling for Better Performance
By default, Linux dynamically adjusts CPU scheduling, but you can 'tweak process priorities' to improve its performance.
Use nice and renice
Use nice
(which affects the process priority level) to start a process with a priority and renice
to adjust it dynamically.
Start a process with a high priority (-10 means higher priority).
nice -n -10 ./my_script.sh
Change priority of an existing process (PID 1234)
renice -5 -p 1234
- 'Nice' values range from -20 (highest priority) to 19 (lowest priority).
- Prioritizing critical workloads makes sure they get more CPU time.
- Only root users can set negative nice
values.
- You could use ps -eo pid,comm,nice
or top
to find current priorities.
2. Increase File Descriptors to Handle More Open Files
By default, Linux limits the number of open files per process and for high-performance web servers or databases, this can be a bottleneck.
Solution: Adjust ulimit
Check the current limit:
ulimit -n
- ulimit -n
only affects the current shell session.
Increase the limit temporarily:
ulimit -n 100000
To make it persistent, edit /etc/security/limits.conf
:
* soft nofile 100000
* hard nofile 200000
Applications like Nginx, MySQL, and Elasticsearch will now be able to handle more concurrent connections.
3. Enable TCP BBR for Faster Network Throughput
Linux's default TCP congestion control (CUBIC) may not be optimal for high-speed networks. BBR (Bottleneck Bandwidth and Round-trip propagation time) significantly improves network performance and reduces latency.
Solution: Enable TCP BBR Check the current congestion control algorithm:
sysctl net.ipv4.tcp_congestion_control
Enable BBR:
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p
BBR significantly improves TCP performance, especially in cloud environments with high-latency or long-distance network connections..
4. Reduce Swappiness to Prevent Unnecessary Disk Swaps
By default, Linux starts using swap space aggressively, which can slow down performance.
Solution: Reduce Swappiness Check current swappiness:
cat /proc/sys/vm/swappiness
Reduce it (default is 60, lower values prefer RAM over swap):
echo "vm.swappiness=10" >> /etc/sysctl.conf
sysctl -p
With this, RAM is used efficiently before swapping to disk, which is much slower.
You can test it temporarily before making it persistent:
echo 10 > /proc/sys/vm/swappiness
5. Optimize Disk I/O Performance with noop Scheduler
For SSDs and cloud-based block storage, Linux's default I/O scheduler (cfq) isn't optimal because it was designed for spinning disk drives, not SSDs.
Solution: Use noop
or deadline
Scheduler
Check current scheduler:
cat /sys/block/sda/queue/scheduler
Set to noop (ideal for SSDs):
echo "noop" > /sys/block/sda/queue/scheduler
For persistent changes, add this to /etc/default/grub:
GRUB_CMDLINE_LINUX="elevator=noop"
Then update Grub:
update-grub && reboot
Overall, it minimizes I/O latency and maximizes SSD performance.
6. Tune Network Buffers for High Traffic Applications
For high-throughput servers (e.g., Nginx, HAProxy), default Linux network buffers may be too low.
Solution: Increase Buffer Sizes
echo "net.core.rmem_max=16777216" >> /etc/sysctl.conf
echo "net.core.wmem_max=16777216" >> /etc/sysctl.conf
echo "net.core.netdev_max_backlog=5000" >> /etc/sysctl.conf
sysctl -p
Prevents packet drops and improves performance for high-bandwidth applications.
7. Enable HugePages for Faster Memory Management
HugePages reduce CPU overhead for memory-intensive applications like databases (PostgreSQL, MySQL).
Solution: Enable HugePages Check current HugePages status:
cat /proc/meminfo | grep HugePages
Enable HugePages (modify /etc/sysctl.conf):
echo "vm.nr_hugepages=1024" >> /etc/sysctl.conf
sysctl -p
This optimizes memory allocation and improves database performance.
8. Use tmpfs for Faster Temporary File Access
If your application reads/writes temporary files frequently, using tmpfs (RAM-based filesystem) is much faster.
Solution: Mount /tmp as tmpfs Edit /etc/fstab:
tmpfs /tmp tmpfs defaults,noatime,nosuid,size=2G 0 0
Mount it:
mount -a
This speeds up caching, builds, and temporary storage.
9. Optimize Systemd Services for Faster Boot and Performance
Some unnecessary background services consume CPU and RAM.
Solution: Disable Unused Services List services consuming boot time:
systemd-analyze blame
Disable unnecessary services:
systemctl disable bluetooth.service
systemctl disable cups.service
This frees up system resources, especially on minimal cloud VMs.
10. Enable CPU Frequency Scaling for Performance or Power Efficiency
Linux dynamically adjusts CPU speed, but you can manually optimize it for performance.
Solution: Use cpufrequtils
Install CPU frequency utilities:
apt install cpufrequtils -y
Set CPU to performance mode (disables power-saving throttling):
cpufreq-set -g performance
For persistent changes, modify /etc/default/cpufrequtils:
GOVERNOR="performance"
Maximum CPU speed is used for high-performance workloads.
11. Use tuned
for Dynamic System Performance Profiles
Linux systems can benefit from automated performance tuning using predefined profiles based on workload types (e.g., virtual hosts, databases, desktops). The tuned
daemon dynamically adjusts system parameters in real-time to match the selected profile.
Solution: Install and use tuned
1. Install tuned: On RHEL/CentOS:
yum install tuned -y
On Ubuntu/Debian:
apt install tuned -y
2. Start and enable the service:
systemctl enable --now tuned
3. List available tuning profiles:
tuned-adm list
4. Apply a performance-optimized profile:
tuned-adm profile throughput-performance
5. Verify the active profile:
tuned-adm active
Some popular profiles include:
- throughput-performance
: Optimizes for network/disk throughput.
- latency-performance
: Ideal for low-latency applications like databases.
- virtual-guest
: Optimized for virtual machines.
- balanced
: General-purpose tuning.
P.S. I recently released a DevOps Starter Kit , a bundle of 20+ Bash scripts, cron jobs, and Docker templates to speed up your infrastructure setup. If you do a lot of server work, you might find it useful.
Reporting a Problem
Sometimes we have problems displaying some Medium posts.
If you have a problem that some images aren't loading - try using VPN. Probably you have problem with access to Medium CDN (or fucking Cloudflare's bot detection algorithms are blocking you).