3
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?

heyを使って負荷テストを試してみた

Last updated at Posted at 2025-06-23

やりたいこと

簡単にサーバの負荷テストを行い、どのくらいの負荷を耐えることが可能か調べたい。

調べているとGo言語で記述されている以下のツールが便利そうでしたので試してみました。

インストール

Macであればbrewでインストールが可能です。

brew install hey

実行

インストールが完了するとすぐに実行することができます。

hey [options...] <url>
# 基本的な使用法
hey https://example.com/

# 500リクエストを100の並列ワーカーで実行
hey -n 500 -c 100 https://example.com/

# 30秒間リクエストを送信
hey -z 30s https://example.com/

-nと-cリクエスト数と同時接続数を調整して、負荷試験をおなっておりました。

実行すると以下のように結果が出力されます。

Summary:
  Total:	177.5970 secs
  Slowest:	11.9748 secs
  Fastest:	0.1367 secs
  Average:	1.1833 secs
  Requests/sec:	56.3073
  

Response time histogram:
  0.137 [1]	|
  1.321 [7077]	|■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  2.504 [601]	|■■■
  3.688 [1455]	|■■■■■■■■
  4.872 [719]	|■■■■
  6.056 [33]	|
  7.240 [23]	|
  8.423 [53]	|
  9.607 [13]	|
  10.791 [10]	|
  11.975 [15]	|


Latency distribution:
  10% in 0.2076 secs
  25% in 0.2269 secs
  50% in 0.2606 secs
  75% in 2.2141 secs
  90% in 3.6619 secs
  95% in 3.7836 secs
  99% in 7.0973 secs

Details (average, fastest, slowest):
  DNS+dialup:	0.0026 secs, 0.1367 secs, 11.9748 secs
  DNS-lookup:	0.0012 secs, 0.0000 secs, 0.1478 secs
  req write:	0.0000 secs, 0.0000 secs, 0.0035 secs
  resp wait:	1.1790 secs, 0.1366 secs, 11.6055 secs
  resp read:	0.0016 secs, 0.0000 secs, 0.1038 secs

Status code distribution:
  [200]	3193 responses
  [500]	6807 responses

リクエスト数「10000」で同時接続「80」で試すと半分以上が500エラーで処理されているのがわかります。
※T系列のEC2で試しました

結果はChatGPTなどに解説させると、対応方針

サーバダウンする可能性がありますので、
運用中の本番サーバへの実施はおすすめしません

まとめ

気軽に負荷テストを実施することができたので、非常に便利なツールでした。
どのくらいのアクセスに耐えることができるかの目安を見るぐらいでしたら、Apache JMeterよりheyが良いと思います!

3
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
3
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?