performance-tuning

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Performance Tuning

性能调优

Optimize Linux system performance.
优化Linux系统性能。

System Monitoring

系统监控

bash
top / htop                # Process monitoring
vmstat 1                  # Memory statistics
iostat -x 1               # Disk I/O
sar -n DEV 1              # Network statistics
perf top                  # CPU profiling
bash
top / htop                # Process monitoring
vmstat 1                  # Memory statistics
iostat -x 1               # Disk I/O
sar -n DEV 1              # Network statistics
perf top                  # CPU profiling

Kernel Parameters

内核参数

bash
undefined
bash
undefined

/etc/sysctl.d/99-performance.conf

/etc/sysctl.d/99-performance.conf

vm.swappiness = 10 net.core.somaxconn = 65535 net.ipv4.tcp_max_syn_backlog = 65535 fs.file-max = 2097152 vm.dirty_ratio = 40 vm.dirty_background_ratio = 10
undefined
vm.swappiness = 10 net.core.somaxconn = 65535 net.ipv4.tcp_max_syn_backlog = 65535 fs.file-max = 2097152 vm.dirty_ratio = 40 vm.dirty_background_ratio = 10
undefined

File Descriptor Limits

文件描述符限制

bash
undefined
bash
undefined

/etc/security/limits.conf

/etc/security/limits.conf

  • soft nofile 65535
  • hard nofile 65535
  • soft nproc 65535
  • hard nproc 65535
undefined
  • soft nofile 65535
  • hard nofile 65535
  • soft nproc 65535
  • hard nproc 65535
undefined

Disk I/O

磁盘I/O调优

bash
undefined
bash
undefined

Change scheduler

Change scheduler

echo noop > /sys/block/sda/queue/scheduler
echo noop > /sys/block/sda/queue/scheduler

Enable trim for SSDs

Enable trim for SSDs

fstrim -av
undefined
fstrim -av
undefined

Network Tuning

网络调优

bash
undefined
bash
undefined

Increase buffers

Increase buffers

sysctl -w net.core.rmem_max=134217728 sysctl -w net.core.wmem_max=134217728
undefined
sysctl -w net.core.rmem_max=134217728 sysctl -w net.core.wmem_max=134217728
undefined

Best Practices

最佳实践

  • Profile before optimizing
  • Change one parameter at a time
  • Monitor impact of changes
  • Document all tuning
  • 优化前先进行性能分析
  • 每次仅修改一个参数
  • 监控参数变更带来的影响
  • 记录所有调优操作