0Pricing
Linux Command Line Mastery · 강의

메모리 및 CPU 성능 도구

`vmstat`, `sar`, `mpstat`과 같은 도구를 활용하여 CPU 및 메모리 관련 성능 문제를 진단합니다.

메모리 및 CPU 성능 도구은(는) CoddyKit의 무료 Linux Command Line Mastery 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Linux Command Line Mastery 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Linux Command Line Mastery 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Diagnose Performance Issues

Understanding system performance is key to troubleshooting slow applications or an unresponsive server. CPU and memory are often the first resources to check.

In this lesson, we'll explore powerful command-line tools to monitor and diagnose issues related to your system's CPU and memory usage.

Meet `vmstat`

The vmstat (virtual memory statistics) command provides a quick, real-time snapshot of your system's activity. It reports on processes, memory, paging, block I/O, traps, and CPU activity.

It's excellent for observing current system behavior and identifying immediate bottlenecks.

`vmstat` Memory Overview

Let's run vmstat 1 1 to see a single report, then we'll break down the memory-related output. This command shows a report every 1 second, for 1 iteration.

  • swpd: amount of virtual memory used.
  • free: amount of idle memory.
  • buff: memory used as buffers.
  • cache: memory used as cache.
vmstat 1 1

`vmstat` CPU Details

Now, let's look at the CPU section of vmstat. Run the command again if you like, and focus on the 'cpu' columns:

  • us (user): time spent running non-kernel code.
  • sy (system): time spent running kernel code.
  • id (idle): time spent idle.
  • wa (wait): time spent waiting for I/O.

High wa often indicates disk bottlenecks.

vmstat 1 1

Introducing `sar`

The sar (System Activity Reporter) command is part of the sysstat package. Unlike vmstat, sar can collect and report historical system activity data.

This makes it invaluable for long-term analysis, identifying trends, and diagnosing intermittent problems that might not be visible with real-time tools.

`sar` for CPU Usage

To view CPU utilization with sar, we use the -u option. Run sar -u 1 1 to get a single report.

  • %user: CPU usage by user-level applications.
  • %system: CPU usage by kernel-level tasks.
  • %iowait: Time CPU spent waiting for I/O.
  • %idle: Time CPU was idle.
sar -u 1 1

`sar` for Memory Usage

To get detailed memory utilization reports with sar, use the -r option. Try sar -r 1 1.

  • kbmemfree: Amount of free memory.
  • kbmemused: Amount of used memory.
  • %memused: Percentage of used memory.
  • kbbuffers: Memory used by kernel buffers.
  • kbcached: Memory used by page cache.
sar -r 1 1

Understanding `mpstat`

The mpstat (multi-processor statistics) command is also part of the sysstat package. Its main advantage is providing per-processor or per-core CPU activity.

This is crucial for systems with multiple CPU cores, as it helps identify if a specific core is overloaded while others are idle.

`mpstat` Per-Core Activity

To see statistics for all individual CPU cores, use mpstat -P ALL 1 1. You'll see a separate line for each core (CPU 0, CPU 1, etc.) and an 'all' line for the average.

This helps pinpoint if a single-threaded application is maxing out one core, even if overall CPU usage seems low.

mpstat -P ALL 1 1

Performance Tool Check

Which of the following statements about Linux performance tools are TRUE?

Recap: CPU & Memory Tools

In this lesson, you learned about three essential tools for monitoring CPU and memory performance:

  • vmstat: For real-time system activity snapshots.
  • sar: For collecting and reporting historical system activity data.
  • mpstat: For detailed per-processor/per-core CPU usage.

Mastering these commands will significantly boost your ability to diagnose and troubleshoot Linux system performance issues.

자주 묻는 질문

“메모리 및 CPU 성능 도구” 강의는 무료인가요?

네 — “메모리 및 CPU 성능 도구” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Linux Command Line Mastery 강의 전체를 잠금 해제할 수 있습니다. Linux Command Line Mastery 강의에는 총 4개의 강의가 포함되어 있습니다.

“메모리 및 CPU 성능 도구”에서 뭘 배우나요?

`vmstat`, `sar`, `mpstat`과 같은 도구를 활용하여 CPU 및 메모리 관련 성능 문제를 진단합니다. 브라우저에서 직접 실행하는 실습 코드로 Linux Command Line Mastery을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Linux Command Line Mastery을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Linux Command Line Mastery은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.

“메모리 및 CPU 성능 도구” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Linux Command Line Mastery 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Linux Command Line Mastery 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 디스크 입출력 모니터링: `iostat`, `iotop`
  2. 메모리 및 CPU 성능 도구
  3. 고급 로그 기록 및 문제 해결 기법
  4. strace와 ltrace로 시스템 호출 추적하기
← Linux Command Line Mastery(으)로 돌아가기