0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【AWS構築】AutoScalingの自動スケーリングを負荷テストで確かめる

Last updated at Posted at 2025-04-11

前提

・AutoScalingグループは作成済みでEC2が1台起動
・EC2にはSSM接続orSSH接続可能

負荷テストの概要

色々Linuxに負荷をかける方法はありますが、今回はFork爆弾というコマンドを使用します。
(リポジトリからパッケージインストールも面倒だしね)

:(){ :|:& };:

上のコマンドは:で定義された関数を無限に呼び出してプロセスを占領するコマンドです。(フォーク爆弾)
Linuxのデフォルトでは、ulimit -uがunlimitedになっているため、無限にプロセスが生成されます。
image.png

使い捨てのEC2とはいえ爆発的に増加するのは怖いので10万ぐらいに上限を制限しておきます。

ulimit -u 100000

image.png

コマンド実行

EC2のモニタリングでCPU使用率(%)メトリクスを確認しましょう。
当たり前ですが、100%になっています。(SSH接続も落ちました)

image.png

AutoScalingグループを確認します。
image.png
↑インスタンスの台数が1台増えて2台になっています。スケーリングされています。

反省

すぐに100%になったので、本当に50%閾値でスケーリングされているのかはよくわからなかった...
stress使う方がテストとしては確実。。。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?