Skip to Content
문서운영시스템 관리성능 튜닝

성능 튜닝

이 기사에서는 하드웨어를 최대한 활용하는 데 도움이 되도록 Ubuntu 26.04에서 일반적으로 사용되는 성능 모니터링 도구 및 최적화 기술을 다룹니다.

시스템 모니터링 도구

htop - 대화형 프로세스 관리자

# Install (usually pre-installed on Ubuntu 26.04) sudo apt install htop # Launch htop

일반적인 htop 작업:

지름길기능
F2설정/구성
F3검색 과정
F4프로세스 필터링
F5트리 보기
F6종류
F9신호 보내기(프로세스 종료)
F10그만두다
u사용자별로 필터링
M메모리별로 정렬
PCPU별로 정렬
T시간순으로 정렬

기타 모니터링 도구

# top - basic process monitoring top # vmstat - virtual memory statistics vmstat 1 5 # once per second, 5 times # iostat - I/O statistics sudo apt install sysstat iostat -xz 1 # iotop - view per-process I/O sudo apt install iotop sudo iotop # nmon - comprehensive performance monitoring sudo apt install nmon nmon # glances - modern system monitoring sudo apt install glances glances # btop - visually appealing resource monitor sudo apt install btop btop

시스템 리소스 정보 보기

# CPU information lscpu cat /proc/cpuinfo | grep "model name" | head -1 # Memory information free -h cat /proc/meminfo # Disk usage df -h # Load averages uptime cat /proc/loadavg # Network connections ss -tunapl

CPU 최적화

CPU 주파수 관리

# cpufrequtils is deprecated; use cpupower instead (provided by linux-tools) sudo apt install linux-tools-common linux-tools-generic # View current CPU frequency and governor cpupower frequency-info # View available frequency governors cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors # Set to performance mode sudo cpupower frequency-set -g performance # Set to power-saving mode sudo cpupower frequency-set -g powersave

데스크탑에서는 더 높은 수준의 전원 관리 도구인 power-profiles-daemon을 사용할 수도 있습니다.

# List available power profiles powerprofilesctl list # Switch to performance mode powerprofilesctl set performance

프로세스 우선순위

# Use nice to start a process (-20 to 19, lower values = higher priority) nice -n 10 /path/to/task.sh # Change the priority of a running process renice -n 5 -p PID # Set real-time priority sudo chrt -f 50 /path/to/realtime-task # Pin a process to specific CPU cores taskset -c 0,1 /path/to/task.sh

메모리 최적화

스왑 튜닝

# View current swap usage swapon --show free -h # View current swappiness value (default is 60) cat /proc/sys/vm/swappiness

교체 매개변수 가이드:

값사용 사례
0-10충분한 메모리를 갖춘 데스크탑 시스템/서버, 스왑 사용량 최소화
30-40일반 서버 워크로드
60기본값
80-100메모리가 제한된 시스템, 스왑을 적극적으로 사용
# Temporarily change swappiness sudo sysctl vm.swappiness=10 # Permanently change swappiness echo "vm.swappiness=10" | sudo tee -a /etc/sysctl.d/99-performance.conf sudo sysctl --system

기타 메모리 매개변수

# Cache pressure (default 100; lower values retain more directory and inode caches) echo "vm.vfs_cache_pressure=50" | sudo tee -a /etc/sysctl.d/99-performance.conf # Dirty page writeback policy echo "vm.dirty_ratio=15" | sudo tee -a /etc/sysctl.d/99-performance.conf echo "vm.dirty_background_ratio=5" | sudo tee -a /etc/sysctl.d/99-performance.conf # Apply all changes sudo sysctl --system

캐시 지우기

# Free page cache sudo sync; echo 1 | sudo tee /proc/sys/vm/drop_caches # Free dentry and inode cache sudo sync; echo 2 | sudo tee /proc/sys/vm/drop_caches # Free all caches sudo sync; echo 3 | sudo tee /proc/sys/vm/drop_caches

I/O 스케줄러

I/O 스케줄러 보기 및 변경

# View current I/O scheduler cat /sys/block/sda/queue/scheduler # Example output: [mq-deadline] kyber bfq none # Temporarily change echo "bfq" | sudo tee /sys/block/sda/queue/scheduler

I/O 스케줄러 선택

스케줄러사용 사례
mq-deadline범용, 대부분의 HDD 및 SSD에 적합
bfq데스크탑 시스템은 더 나은 대화형 응답성을 제공합니다.
kyber고성능 NVMe SSD
noneNVMe SSD 직접 액세스, 최저 대기 시간

I/O 스케줄러 설정 유지

udev 규칙을 만듭니다.

sudo nano /etc/udev/rules.d/60-scheduler.rules
# HDD uses mq-deadline ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="mq-deadline" # SSD uses none or mq-deadline ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="mq-deadline" # NVMe uses none ACTION=="add|change", KERNEL=="nvme[0-9]*", ATTR{queue/scheduler}="none"
sudo udevadm control --reload-rules

SSD 최적화

TRIM 활성화

TRIM을 사용하면 운영 체제가 SSD에 더 이상 사용되지 않는 데이터 블록을 알려 SSD 성능을 유지하고 수명을 연장할 수 있습니다.

# Check if the SSD supports TRIM sudo hdparm -I /dev/sda | grep TRIM # Manually run TRIM sudo fstrim -v / # Check the scheduled TRIM service systemctl status fstrim.timer # Enable scheduled TRIM (runs weekly) sudo systemctl enable --now fstrim.timer

fstab의 SSD 최적화 옵션

# Recommended SSD mount options UUID=xxxx / ext4 defaults,noatime,discard 0 1
옵션설명
noatime파일 액세스 시간을 기록하지 않고 쓰기를 줄입니다.
discard실시간 TRIM(또는 대신 fstrim.timer 사용)
commit=60커밋 간격 연장, 쓰기 빈도 감소

불필요한 디스크 쓰기 줄이기

# Mount /tmp to memory # Add to /etc/fstab: # tmpfs /tmp tmpfs defaults,noatime,size=2G 0 0 # Reduce journal writes sudo nano /etc/systemd/journald.conf # Set: Storage=volatile (memory only, lost after reboot) # Or: SystemMaxUse=100M (limit journal size)

네트워크 최적화

TCP 매개변수 튜닝

sudo nano /etc/sysctl.d/99-network.conf
# TCP buffer sizes net.core.rmem_max=16777216 net.core.wmem_max=16777216 net.ipv4.tcp_rmem=4096 87380 16777216 net.ipv4.tcp_wmem=4096 65536 16777216 # TCP connection optimization net.ipv4.tcp_fastopen=3 net.ipv4.tcp_mtu_probing=1 net.ipv4.tcp_congestion_control=bbr # Connection queue net.core.somaxconn=65535 net.core.netdev_max_backlog=65535 # TIME_WAIT optimization net.ipv4.tcp_tw_reuse=1 net.ipv4.tcp_fin_timeout=15
# Enable BBR congestion control echo "net.core.default_qdisc=fq" | sudo tee -a /etc/sysctl.d/99-network.conf echo "net.ipv4.tcp_congestion_control=bbr" | sudo tee -a /etc/sysctl.d/99-network.conf sudo sysctl --system # Verify BBR is active sysctl net.ipv4.tcp_congestion_control

파일 시스템 최적화

ext4 최적화

# View filesystem parameters sudo tune2fs -l /dev/sda2 # Reduce reserved space (default 5%, can be lowered for large partitions) sudo tune2fs -m 1 /dev/sda2

파일 설명자 제한

# View current limit ulimit -n # Temporarily increase the limit ulimit -n 65535 # Permanently change sudo nano /etc/security/limits.conf
# /etc/security/limits.conf * soft nofile 65535 * hard nofile 65535

시스템 수준:

echo "fs.file-max=2097152" | sudo tee -a /etc/sysctl.d/99-performance.conf sudo sysctl --system

부팅 최적화

# Analyze boot time systemd-analyze # View boot time per service systemd-analyze blame # View critical boot path systemd-analyze critical-chain # Disable unnecessary services sudo systemctl disable bluetooth.service # not using Bluetooth sudo systemctl disable cups.service # not using printing sudo systemctl disable ModemManager.service # not using modem # Check boot log for errors journalctl -b -p err

성능 벤치마킹

# Disk performance test sudo apt install fio # Sequential read test fio --name=seqread --rw=read --bs=1M --size=1G --numjobs=1 --runtime=30 # Random read/write test fio --name=randreadwrite --rw=randrw --bs=4k --size=1G --numjobs=4 --runtime=30 # Simple disk write speed test dd if=/dev/zero of=/tmp/testfile bs=1M count=1024 oflag=direct # Memory bandwidth test sudo apt install sysbench sysbench memory run # CPU benchmark sysbench cpu --threads=$(nproc) run # Network performance test sudo apt install iperf3 # Server: iperf3 -s # Client: iperf3 -c server_ip