1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

サーバーメモリ使用量超シンプル調査方法

Last updated at Posted at 2023-03-09

サーバーのトータルメモリ使用量

free -h

個別プロセスを調べる

基本形

ps axu
  • a : 端末を持つすべてのプロセスを表示
  • x : 端末を持たないすべてのプロセスを表示
  • u : 他のユーザーが実行しているプロセスも含めて表示する

Nginx などは端末を持たないし、他のユーザーが実行している場合がほとんどなので、ひとまず、このps コマンドが基本です。

複数プロセスが立ち上がるプログラムのメモリ合計を測る

サーバー内で複数プロセスが立ち上がっている場合に、合計使用メモリ量を測るためのコマンドです。

例えば php-fpm など

フォーマット

ps aux | grep [プロセス名] | awk '{sum += $6}END{print sum}'

メモリの単位はキロバイトででます。

サーバーの PHP-FPM プロセスのメモリ使用量合計を調べます。

ps aux | grep php-fpm | awk '{sum += $6}END{print sum}'

起動プロセス数を調べる

1プロセスあたりの使用メモリ数を出すために、起動しているプロセス数を調べます。

ps aux | grep [プロセス名] | wc -l

php-fpm

ps aux | grep php-fpm | wc -l

これで、「メモリ使用量合計」÷「起動プロセス数」で1プロセス数あたりのメモリ使用量がわかります。

ISO 127001 認証を取得しているセキュアかつ簡単な操作が可能で開発もしやすい Concrete CMS のサイト用のサーバー構築の際の設定の参考で必要でした。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?