25 Proven Linux Performance Tuning Tricks to Boost System Speed
Learn 25 practical Linux performance tuning techniques—from adjusting kernel parameters like swappiness and ulimit to optimizing I/O schedulers, network buffers, and enabling HugePages—each with clear commands and step‑by‑step instructions to help you maximize system responsiveness and throughput.
Linux system performance tuning is a multi‑layered process that involves kernel parameter tweaks, hardware configuration, and application‑level adjustments. The following 25 tips provide concrete commands and actions to improve overall system efficiency.
1. Adjust swappiness Parameter
Tip: Reduce reliance on swap to improve memory usage efficiency.
Action: Set a lower value (e.g., 10) in /proc/sys/vm/swappiness so the system prefers physical memory.
sysctl vm.swappiness=102. Monitor System Resources with top and htop
Tip: Regularly use top or the more visual htop to view CPU, memory, and load, identifying performance bottlenecks.
3. Adjust ulimit Settings
Tip: Increase the limit of open file descriptors for processes to avoid resource exhaustion under high load.
Action: Edit /etc/security/limits.conf and add:
* hard nofile 65535
* soft nofile 655354. Optimize I/O Scheduler
Tip: Choose an appropriate I/O scheduler for the workload (e.g., noop for SSD, deadline for low‑latency apps).
Action: Change the scheduler:
echo noop > /sys/block/sda/queue/scheduler5. Use vmstat to Monitor System Performance
Tip: View detailed CPU, memory, and I/O statistics to understand load and adjust promptly.
vmstat 16. Adjust dirty_ratio and dirty_background_ratio
Tip: Optimize write‑back cache flushing frequency to reduce disk I/O pressure.
sysctl vm.dirty_ratio=15
sysctl vm.dirty_background_ratio=57. Enable Huge Pages
Tip: For memory‑intensive applications (e.g., databases), enable huge pages to lower allocation overhead.
Action: Add to /etc/sysctl.conf:
vm.nr_hugepages=2568. Adjust Kernel Parameter net.core.somaxconn
Tip: Increase the server's connection queue length to avoid refusals under high concurrency.
sysctl -w net.core.somaxconn=10249. Optimize Network Buffers
Tip: Increase network buffer sizes to prevent packet loss under heavy load.
sysctl -w net.core.rmem_max=16777216
sysctl -w net.core.wmem_max=1677721610. Disable Unnecessary Services
Tip: Turn off services you do not need to reduce resource consumption.
Action: Use systemctl disable or chkconfig to disable them.
11. Monitor Disk Performance with iostat
Tip: Regularly check disk I/O performance to detect bottlenecks.
iostat -x 112. Adjust tcp_tw_reuse and tcp_tw_recycle
Tip: Reduce the number of TIME_WAIT sockets for short‑lived connections.
sysctl -w net.ipv4.tcp_tw_reuse=1
sysctl -w net.ipv4.tcp_tw_recycle=113. Use tuned for Automatic System Optimization
Tip: Install tuned and select a profile that automatically adjusts kernel parameters for the system role.
yum install tuned
tuned-adm profile throughput-performance14. Enable Asynchronous I/O (AIO)
Tip: For high‑performance I/O workloads (e.g., databases), enable AIO to increase parallelism.
15. Adjust Filesystem Mount Options
Tip: Use the noatime option to avoid updating access times on each read, reducing disk I/O.
Action: Edit /etc/fstab and add noatime:
/dev/sda1 / ext4 defaults,noatime 0 016. Accelerate DNS Resolution with nscd
Tip: Cache DNS queries to speed up frequent network requests.
Action: Install and start nscd:
yum install nscd
systemctl start nscd17. Disable Unnecessary Kernel Modules
Tip: Unload modules you do not need to free memory and CPU cycles.
Action: List loaded modules with lsmod and remove them using modprobe -r.
18. Analyze Performance with perf
Tip: Use perf to identify application bottlenecks for targeted tuning.
perf top19. Optimize Process Scheduling
Tip: Assign higher scheduling priority to critical tasks using chrt.
chrt -f 99 <process-id>20. Adjust TCP Window Size
Tip: Increase the TCP window to improve throughput on high‑latency networks.
sysctl -w net.ipv4.tcp_window_scaling=1
sysctl -w net.core.rmem_default=262144
sysctl -w net.core.wmem_default=26214421. Enable Transparent Huge Pages (THP)
Tip: Activate THP to boost performance for applications requiring large memory blocks.
Action: Set /sys/kernel/mm/transparent_hugepage/enabled to always.
echo always > /sys/kernel/mm/transparent_hugepage/enabled22. Adjust tcp_fin_timeout
Tip: Reduce the wait time for closed TCP connections to free resources faster.
sysctl -w net.ipv4.tcp_fin_timeout=1523. Use SSDs for Faster Read/Write
Tip: Replace HDDs with SSDs for high‑I/O workloads to dramatically improve performance.
24. Enable NUMA (Non‑Uniform Memory Access) Optimization
Tip: On multi‑core systems, enable NUMA to exploit memory locality.
Action: Use numactl to interleave memory across nodes:
numactl --interleave=all <application>25. Speed Up Boot with systemd-analyze
Tip: Analyze boot time and disable services that cause delays. systemd-analyze blame Applying the relevant tips based on your workload can significantly improve overall Linux system performance and responsiveness.
Java Architecture Stack
Dedicated to original, practical tech insights—from skill advancement to architecture, front‑end to back‑end, the full‑stack path, with Wei Ge guiding you.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
