開発サイクル全体で構築しているWebアプリケーションの負荷テストを実行できるようにすることを目的として、Javaで独自の負荷テストツールを構築したいと思います。Webアプリケーションはサーバー間HTTPPostリクエストを受信します。平均応答時間とともに、1秒あたりの開始トランザクション(TPS)容量を確認したいと思います。
PostリクエストとレスポンスメッセージはXMLになります(私はそれが本当に当てはまるとは思いませんが:))。
トランザクションを送信し、1秒間(1000ミリ秒)に送信できたトランザクションの数をカウントする非常に単純なJavaアプリを作成しましたが、これが負荷テストの最良の方法ではないと思います。本当に私が欲しいのは、10、50、100などの任意の数のトランザクションをまったく同時に送信することです。
どんな助けでもいただければ幸いです!
ああ、これが私の現在のテストアプリコードです:
Thread[] t = new Thread[1];
for (int a = 0; a < t.length; a++) {
t[a] = new Thread(new MessageLoop());
}
startTime = System.currentTimeMillis();
System.out.println(startTime);
for (int a = 0; a < t.length; a++) {
t[a].start();
}
while ((System.currentTimeMillis() - startTime) < 1000 ) {
}
if ((System.currentTimeMillis() - startTime) > 1000 ) {
for (int a = 0; a < t.length; a++) {
t[a].interrupt();
}
}
long endTime = System.currentTimeMillis();
System.out.println(endTime);
System.out.println("Total time: " + (endTime - startTime));
System.out.println("Total transactions: " + count);
private static class MessageLoop implements Runnable {
public void run() {
try {
//Test Number of transactions
while ((System.currentTimeMillis() - startTime) < 1000 ) {
// SEND TRANSACTION HERE
count++;
}
}
catch (Exception e) {
}
}
}