21 Ekim 2023 Cumartesi

Apache Benchmark Aracı - ab komutu

Giriş
JMeter yerine Apache Benchmark kullanılabilir.  Büyük miktarda trafik yaratır yani Load testing için kullanılabilir. Açıklaması şöyle
Apache benchmark is a simple-to-use tool to help you understand how an HTTP server copes with large volumes of traffic. 
...
Note that Apache Benchmark will fire off requests as fast as it possibly can, given the permitted concurrency. It’s hard to say “send 1000 requests over the space of 1 minute” — it will just do 1000 requests as fast as possible. Therefore, it’s kind of tricky to simulate a realistic load. AB is generally better for finding out at what point your service begins to degrade, and then ascertaining whether you could ever reasonably expect this load.


Windows Kurulum
https://www.youtube.com/watch?v=hUZso9TpEes adresinde Windows'a nasıl kurulacağı gösteriliyor

MacOS Kurulum
Kurmaya gerek yok, kurulu geliyor

Çıktısı
Connection times başlığı altında Total isimli satırdaki median isimli sütun iyi bir fikir verebilir.

Örnek
Şöyledir
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       4
Processing:    19   76   2.9     76      88
Waiting:        2   55  13.4     56      87
Total:         19   76   2.9     76      88

Percentage of the requests served within a certain time (ms)
  50%     76
  66%     77
  75%     77
  80%     77
  90%     79
  95%     81
  98%     83
  99%     84
 100%     88 (longest request)

-c seçeneği
Kaç tane thread kullanılacağını belirtir. Toımcat varsayılan 200 thread ile başladığı için genellikle 200'den büyük bir değer vermek gerekir.

Örnek
Şöyle yaparız. Burada 100 tane thread kullanılıyor
ab -c 100 http://localhost:8080/
-n seçeneği
İstek sayısını belirtir.

Örnek
Şöyle yaparız
ab -n 1000 -c 1000 http://localhost:8080/thread-application/run
-r seçeneği
Açıklaması şöyle
The  -r flag means don’t exit if it gets an error. 
Örnek
Şöyle yaparız
$ ab -c 10 —n 500 —r localhost:8000/api/books
-T seçeneği
Açıklaması şöyle
By default, AB will perform a GET request so if you need to test another type of request you will have to pass it the specific option to do so and also set the content-type header of the request with the -T flag.
Örnek - POST
Şöyle yaparız. Burada -p ile event.json dosyası POST ediliyor.
$ ab -c 10 -n 500 -p event.json -r -T application/json localhost:8000/api/books




Hiç yorum yok:

Yorum Gönder