Master Linux Performance: Key Factors and Essential Optimization Tools
This article examines the various hardware and OS resources that affect Linux performance—including CPU, memory, disk I/O, and network bandwidth—then details practical optimization techniques and essential monitoring tools such as vmstat, iostat, free, sar, and netstat to diagnose and improve system efficiency.
1. Factors Affecting Linux Performance
1. System Hardware Resources
(1) CPU
How to determine multi‑core CPUs versus hyper‑threading; CPU‑intensive services include dynamic web services and mail services.
(2) Memory
Trade‑off between physical memory and swap.
Choosing a 64‑bit Linux distribution.
Memory‑intensive services include in‑memory databases such as Redis, HBase, and MongoDB.
(3) Disk I/O
RAID technologies (RAID0/1/5/01/10).
SSD disks.
Disk‑intensive workloads are typically database servers.
(4) Network Bandwidth
Selection of NICs and switches.
Operating‑system level NIC bonding.
Bandwidth‑heavy services include Hadoop platforms and video streaming platforms.
2. OS‑Related Resources
(1) System Installation Optimization
Disk partitioning, RAID configuration, and swap settings.
(2) Kernel Parameter Tuning
ulimit -n (maximum open files) and ulimit -u (maximum user processes).
(3) File System Optimization
ext2 – standard Linux file system without journaling.
ext3 – adds journaling; supports up to 32,000 sub‑directories.
ext4 – successor to ext3, unlimited sub‑directories, fast fsck (supported since kernel 2.6.28).
xfs – high‑performance file system, default since kernel 3.10.
Recommendations:
Read‑intensive workloads with many small files: prefer ext4, then xfs, then ext3.
Write‑intensive workloads: prefer xfs, then ext4, then ext3.
Low performance or low data‑safety requirements: ext3 is a good choice.
3. Application Issues
These require developers to inspect code, but operations staff should provide strong evidence of program‑related problems.
2. Linux Performance Optimization Tools
1. CPU Performance Evaluation Tools
(1) vmstat (built‑in)
Monitors memory, process states, and CPU activity. Common usage: vmstat 2 3 (updates every 3 seconds, three samples).
Key fields:
procs – r column: number of processes running or waiting for a CPU slice; sustained values higher than CPU count indicate CPU shortage.
procs – b column: processes waiting for I/O or swapping.
memory – swpd: memory swapped out (KB). Non‑zero values are normal if si/so remain zero.
memory – free: free physical memory (KB).
memory – buff: buffer cache size.
memory – cache: page cache size; large cache with low bi indicates efficient filesystem.
swap – si: memory swapped in from disk.
swap – so: memory swapped out to disk; sustained non‑zero values indicate memory pressure.
IO – bi: blocks read per second; bo: blocks written per second. bi+bo > 1000 with high wa suggests disk I/O problems.
system – in: interrupts per second; cs: context switches per second. High values increase kernel CPU usage.
CPU – us: user‑space CPU usage; sy: kernel‑space CPU usage. us + sy > 80 % may indicate CPU saturation.
CPU – id: idle percentage.
CPU – wa: I/O wait percentage; wa > 20 % signals serious I/O wait.
(2) iostat (requires sysstat package)
Provides I/O statistics. Common usage: iostat -c 3 5 (CPU stats every 3 seconds, five samples). Use -d for disk stats.
(3) uptime
Shows current time, system uptime, number of logged‑in users, and load averages for 1, 5, 15 minutes.
2. Memory Performance Evaluation
(1) free
Shows memory usage. Typical usage: free -m. Important columns are free and cached. Example analysis: a system with 8 GB RAM, 925 MB free, 243 MB buffer cache, 6299 MB page cache, leaving ~7468 MB usable memory, indicating ample memory resources.
Rule of thumb: usable memory / total physical memory > 70 % → resources are abundant; <20 % → memory shortage; 20‑70 % → generally acceptable.
(2) sar / pidstat
Monitor CPU, memory, and I/O for all or specific processes. Common options: -u (CPU), -r (memory), -d (disk). Example commands: sar -u 3 – CPU stats every 3 seconds. pidstat -r -p 1 3 – memory stats for PID 1 over 3 seconds.
Output fields include Kbmemfree, Kbmemused, %memused, kbbuffers, kbcached, kbcommit, and %commit. sar’s output aligns with free but adds percentages and averages.
3. Disk Performance Evaluation
(1) iostat -d
Example: iostat -d 2 3. Output fields: Blk_read/s – blocks read per second. Blk_wrtn/s – blocks written per second. Blk_read – total blocks read. Blk_wrtn – total blocks written.
(2) pidstat -d -p <pid> 3
(3) sar -d 2 3
Provides detailed disk I/O metrics such as tps, rd_sec/s, wr_sec/s, avgrq‑sz, avgqu‑sz, await, svctm, and %util. Interpretation: avgrq‑sz – average request size (like items per shopper in a supermarket). avgqu‑sz – average queue length (people waiting). await – average wait time per I/O request. svctm – average service time (cashier speed). %util – proportion of time the device was busy; values near 100 % indicate a bottleneck.
Generally, svctm should be less than await. A high await relative to svctm signals long I/O queues and degraded performance.
4. Network Performance Evaluation
(1) ping
Shows round‑trip time (ms) and packet loss; high latency or loss indicates network issues.
(2) netstat
Use netstat -i to view interface statistics and netstat -r for routing tables.
(3) mtr / traceroute
Trace network routes; mtr provides dynamic, real‑time path analysis, useful for diagnosing network problems.
3. System Performance Analysis Standards
These standards combine the metrics described above to form a comprehensive view of CPU, memory, disk, and network health, guiding administrators in capacity planning and troubleshooting.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
