※当サイトの記事には、広告・プロモーションが含まれます。

Javaアプリケーションの性能試験(負荷テスト)ができるApache JMeterとは?

www.bbc.com

Googleって1998年に創業で、25年目なんですね。Microsoftの創業が1975年らしいので、Googleさん意外に歴史ありますね。

負荷テストとは?

Wikipediaさんによりますと、

負荷テストという用語は、プロのソフトウェアテスト業界ではさまざまな方法で使用される。負荷テストとは、一般に、プログラムに同時にアクセスする複数のユーザーをシミュレートすることにより、ソフトウェアプログラムの予想される使用法をモデル化する方法を指す。

負荷テスト - Wikipedia

⇧ とのこと。

「性能試験」については、

パフォーマンステスト (: performance testing)はソフトウェア品質保証では、一般に、特定のワークロードでの応答性と安定性の観点からシステムがどのように機能するかを判断するために実行されるテスト手法である。

ソフトウェアパフォーマンステスト - Wikipedia

また、スケーラビリティ信頼性、リソース使用量など、システムの他の品質属性を調査、測定、検証、または検証するのにも役立つ。

ソフトウェアパフォーマンステスト - Wikipedia

種類

負荷テスト

負荷テストは、パフォーマンステストの最も単純な形式である。負荷テストは通常、特定の予想される負荷の下でのシステムの動作を理解するために実行される。

ソフトウェアパフォーマンステスト - Wikipedia

⇧ となっており、Wikipediaの情報が正しい仮定した場合、

  • 性能試験(パフォーマンステスト)
    • 負荷テスト
    • ストレステスト
    • ソークテスト
    • スパイクテスト
    • ブレークポイントテスト
    • 構成テスト
    • 分離テスト
    • インターネットテスト

というカテゴリー分類となるっぽい。

テスト専門に扱うテスターが必要になるのも肯けるほど、考慮すべき事項と必要な作業が多いですかね...

性能試験(負荷テスト)で使えるツール

「負荷テスト」で利用できるツールとしては、

pr.hedgehog-loader.io

⇧ 上記サイト様の情報と、Wikipediaの「負荷テスト」のページの情報を合わせると、

  1. Apache Bench
  2. Locust
  3. k6
  4. Tsung
  5. Vegeta
  6. Apache JMeter
  7. BlazeMeter
  8. Blitz
  9. Flood
  10. Gatling
  11. Loader.io
  12. LoadRunner
  13. Load Test (included with SOAtest)
  14. loadUI
  15. Login VSI
  16. NeoLoad
  17. OpenSTA
  18. Rational Performance Tester
  19. Siege
  20. Silk Performer
  21. Test Studio
  22. Visual Studio Enterprise edition
  23. WebLOAD

の数のツールが挙げられている、多いな...。

テストを適応する領域などによって、適したツールは変わってくるとは思うのだけど、Javaアプリケーションに関する「性能試験(負荷テスト)」に利用するツールとしては、「Apache JMeter」がメジャーのようです。

と言うか、ネットの情報で上位表示されるのが、ほぼ「Apache JMeter」しか出て来ないので、とりあえず、Javaアプリケーションに関する「性能試験(負荷テスト)」は「Apache JMeter」を使っておけば良いってことなんかね?

Javaアプリケーションの性能試験(負荷テスト)ができるApache JMeterとは?

公式のドキュメントによりますと、

jmeter.apache.org

The Apache JMeter application is open source software, a 100% pure Java application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions.

https://jmeter.apache.org/

⇧ とあるので、純度100%のJava製で、性能を測定する用途に特化したツールらしい。

Webアプリケーションのテストのために設計されてるとあるので、Javaアプリケーション以外にもテストできるようですね。

基本的には、

github.com

⇧ 適当なフォルダにダウンロードして、展開(解凍)して、binディレクトリに移動して、JMeterを起動する実行ファイルを実行すれば良いようです。

ただ、ネットの情報を見た感じだと、

⇧ どうも、「Apache JMeter」が、

  • Server Agent
  • Client

で分かれてるっぽいように見えるんだが...

どうやら、

jmeter-plugins.org

JMeter cannot retrieve by default server metrics except Tomcat ones. To overcome this situation, we have developed a server agent which will get performance data for JMeter. The agent uses the SIGAR open source library. It is composed of a Java common part and native libraries per OS.

https://jmeter-plugins.org/wiki/PerfMon/

⇧「Apache JMeter」のみだと、Tomcat以外のメトリクスが取得できないってことらしいのでプラグインを導入しろってことみたい...

⇧ 検証したい対象に「Server Agent」を配置するってことらしいのだけど、

github.com

Agent application to access system metrics on remote machines.

⚠️ It's very out-of-date for modern technology

Since it relies on SIGAR library to gather metrics, with that library last updated in 2010, ServerAgent won't work on many modern systems.

https://github.com/undera/perfmon-agent/tree/master

⇧ え~っと...何かモダンなシステムで機能しないってあるんだけど...

え?プラグイン使えないやん...

公式のドキュメントによりますと、

jmeter.apache.org

Once you've made sure the systems are ready, it's time to setup remote testing. The tutorial assumes you already have JMeter installed on all the systems. The way JMeter works is one controller node initiates the test on multiple worker nodes.

https://jmeter.apache.org/usermanual/jmeter_distributed_testing_step_by_step.html

⇧ すべてのシステムに「JMeter」をインストールしろってなってますね...

GitHubのドキュメントに見当たらなかったので裏メニューな感じなのかもしれないですが、

Before we dive into the step-by-step instructions, it's a good idea to define the terms and make sure the definition is clear.

Controller Node
the system running JMeter GUI, which controls the test
Worker Node
the system running jmeter-server, which takes commands from the GUI and send requests to the target system(s)
Target
the webserver we plan to stress test

https://jmeter.apache.org/usermanual/jmeter_distributed_testing_step_by_step.html

⇧ どうやら、「Apache JMeter」を起動する際に「Control Node」として動作させるか「Worker Node」として動作させるかで利用する実行ファイルが異なるみたい...

何故、GitHubのドキュメントの目立つところに記載しないのか...

GitHubの「bin」ディレクトリを確認してみたところ、

github.com

⇧ 確かに「jmeter」「jmeter-server」の2つ用意されてるっぽい。

ドキュメントを確認した感じでは、

jmeter.apache.org

There are some additional scripts in the bin directory that you may find useful. Windows script files (the .CMD files require Win2K or later):

jmeter.bat
run JMeter (in GUI mode by default)
jmeterw.cmd
run JMeter without the windows shell console (in GUI mode by default)
jmeter-n.cmd
drop a JMX file on this to run a CLI mode test
jmeter-n-r.cmd
drop a JMX file on this to run a CLI mode test remotely
jmeter-t.cmd
drop a JMX file on this to load it in GUI mode
jmeter-server.bat
start JMeter in server mode
mirror-server.cmd
runs the JMeter Mirror Server in CLI mode
shutdown.cmd
Run the Shutdown client to stop a CLI mode instance gracefully
stoptest.cmd
Run the Shutdown client to stop a CLI mode instance abruptly

https://jmeter.apache.org/usermanual/get-started.html

⇧ とのこと。

ドキュメントの記述を発見する前に、

dzone.com

⇧ 上図を見付けて、複数の「Apache JMeter」をインストールするなんて、そんな戯けた構成をする大空け者は誰だい?って思ったことを反省いたします...

Apache JMeter」の公式のドキュメントに、メトリクスを収集したい対象のアプリケーションが配置されているマシン以外のマシンに「Apache JMeter」をインストールするように書いてあったんだものね...

メトリクスを収集したい対象のアプリケーションがコンテナ化されてる場合は、

apim.docs.wso2.com

⇧ 上図のようなイメージの構成になる感じですかね。

ただ、普通に考えたら、Client(GUIで操作できると想定)の「Apache JMeter」は、WindowsもしくはMacにインストールすることになると思うから、Serverの「Apache JMeter」は別マシンを用意してインストールする感じになるんかな?

FAQを見た感じでは、

cwiki.apache.org

How to do remote testing the 'proper way'?

Answer: Here are a few notes to help you on your way.

You have:

  1. Your application server. You shouldn't run anything on this machine that you wouldn't have running on it in your proposed or actual production environment (if you are running anything else, including JMeter, you will be adding load to the server and thus tainting your results).
  2. One or more machines running jmeter-server (the JMeterEngine). You want these machines to be reasonably close (network wise) to the application server. By "reasonably close" I mean on the same Ethernet segment or at least with no low speed links between them. The JMeter User Manual provides reasonable information about doing this.
  3. A single machine running the JMeter GUI that you use to control the machines running the JMeterEngine.

https://cwiki.apache.org/confluence/display/JMETER/JMeterFAQ#JMeterFAQ-HowdoIensuretheremotejmeterservercancommunicatewiththemasterclient?

⇧ とある。

Apache JMeter」が動作するOSとしては、

cwiki.apache.org

⇧ 上記の通り。

なので、マシンとしては、

の3台構成になる感じなんですかね?

ドキュメントのどの部分が「Apache JMeter」を適切に動作させる環境を構築する方法になっているのかが分かり辛い...

分かり辛いと感じているのは自分だけかもしれんけど...

というか、『How to do remote testing the 'proper way'?』ってFAQになってる時点で、ドキュメントを見ても分からないんだが、って人が一定数板ってことだとは思うけど。

そもそも、「Apache JMeter」のGitHub の情報だと「Apache JMeter」のServerとして動作させる点については全く触れられていないので、「クライアントサーバーモデル」の構成になってなくても利用できるのかもしれんので、

  • Apache JMeter」を「クライアントサーバーモデル」の構成で利用する
  • Apache JMeter」を「クライアントサーバーモデル」ではない構成で利用する

で、また用意しなきゃならなんマシンの構成が変わってくるよね...

クラウド環境になってくると、また構成が変わってくるとは思うけど...

毎度モヤモヤ感が半端ない...

今回はこのへんで。