Jmeter Find Data Ussage Per Request - jmeter

I have build a jMeter test for a mobile web application. The test works perfect and i would see how much data a request cost for the mobile data bundle of the user. Is it possible ?

For downloaded data there are 2 ways to achieve this:
Approximation of downloaded data: Summary Report has
Avg. Bytes - average size of the sample response in bytes.
You could use its value to approximate how much data is downloaded by summing up # Samples x Avg. Bytes over all requests.
If you want more precision, and estimation of both uploaded and downloaded data, you can use one of the programmable listeners (BeanShell listener, BSF Listener or JSR223 Listener) and collect this stats by yourself: they all have access to SampleResult, which allows you to collect the size of the uploaded data (sampleResult.getSamplerData().length()) and the size of the downloaded data (sampleResult.getHeadersSize() + sampleResult.getBodySize()). You can then write this data into file (this is an example for BeanShell)

Add next 2 lines to user.properties file (it is located under /bin folder of your JMeter installation)
jmeter.save.saveservice.print_field_names=false
jmeter.save.saveservice.bytes=true
It will "tell" JMeter to store response size and also adds a header to generated .jtl file when you run your test in command-line non-GUI mode so you could figure out which columns stands for which metric.
You'll need to restart JMeter to pick the properties up.
You'll get something like:
So you will be able to use Excel or equivalent to sum all the "bytes" lines up and calculate the associated cost.
See Apache JMeter Properties Customization Guide for more information on what else can be controller with JMeter properties and what needs to be done to apply the changes.

Related

Can we segregate data used based on the View Results in tree Listener?

We have used let say 500 different data for the same operation and out of which 250 are failed and other 250 is passed.
Do we have any script or method so that i can modify something in property file and segregate that failed data and write that data in some csv or excel file.
You need to create two View Results tree Listeners, with two separate files.
One with Log/Display Only: field mark as Errors and other as Successes.
This way errors and successes will be segregated.
Check out Sample Variables property. You can store JMeter Variables values for each sample result using simple configuration like:
Add the next line to user.properties file (lives in "bin" folder of your JMeter installation)
sample_variables=foo,bar
Next time when you run a JMeter test you will see 2 new extra columns in .jtl results file, foo and bar which will hold the values for the relevant JMeter variables.
This way you will be able to figure out what data presumably causes failure (if it is connected with the input data).
More information:
Configuring JMeter
Apache JMeter Properties Customization Guide
Results File Configuration

Http load testing with bytes counting

I need some possibility to conduct load testing of our REST API with traffic counting.
For example to run 20 concurrent user for 1 hour. As a result I want to get information about responses (avg time, delays, etc) and overall traffic that has been produced.
I overlooked JMeter and Gatling, but found no possibilities to count bytes.
I don't really need big amount of concurrent users (100 would be enough) and high throughput (more than 10 requests per second from single user).
My goal is just to produce some load on our system and to check that it shows correct statistic data.
JMeter (checked with latest 3.3) already save sent/received bytes by default, you can see in Listener's Configure button:
Save sent bytes count
Save received bytes count
You will get in jtl file saved columns ..,bytes,sentBytes..
By default JMeter should be saving sent and received bytes in .jtl results file
If it doesn't - add the next lines to user.properties file (lives in "bin" folder of your JMeter installation)
jmeter.save.saveservice.bytes=true
jmeter.save.saveservice.sent_bytes=true
Also make sure you have HttpClient4 implementation selected on the "Advanced" tab of HTTP Request sampler (or HTTP Request Defaults)

In Summary report csv,how to add Average, Min and Max when running from console

When I run the test in GUI, i see the Average, Min, Max in GUI. But when I run in console, is there a way to add these to the csv file?
These values are being calculated so you will be able to see the values only when you open .jtl results file after test finishes in the listener of your choice, i.e. Aggregate Report or Summary Report.
If you want to see the interim statistics while your test is being executed you have the following choices:
JMeter Summarizer output. JMeter reports some numbers into stdout while your test is being running
You can get some extended information if you run your JMeter test using Taurus tool as a wrapper
Both console and web interface options are available, in order to see current test execution stats in browser start your test like:
bzt yourtest.jmx -report
And finally you can use Backend Listener to send your results into database, message queue or web service and use custom plotting application to print out either raw or parsed statistics, here you are limited only by your fantasy:
More information:
JMeter: Real Time Results
How to Use Grafana to Monitor JMeter Non-GUI Results
JMeter produces some basic fields/result_field. JMeter doesn't create everything you see in different types of Listeners.
You can give this a try.
Create a plan
Generate atleast 100 samples (As large amount of data is required for some listeners), using a single sampler (request)
Use as many Listeners as you want of different types (say 15 types of listeners)
Run the plan....
Now in the filename field of all the listeners give series of names of files like a1.jtl a2.jtl
and so on....
see the screen shot
enter image description here
Now again run the plan. Go to the files and open them in some good editors like notepad++.
For your surprise you will find the same data in all the files irrespective of the type of listener generating the file.
Crux of the matter is : JMeter gathers only handful of information from the run, the rest information which is shown in different Listeners is COMPUTED by the JMeter.
So you can read the *.jtl file into any of the listener.
In JMeter, the new way since 3.0 to have results is to use the Web report generated at end of test:
http://jmeter.apache.org/usermanual/generating-dashboard.html

Autosaving Jmeter reports summary form non GUI

I'm using Jmeter for various performance and load tests and would like to save summary of Summary report and aggregate report automatically when test is done.
Usually summary table when you running form GUI looks like this :
Label | Samples | Average | Min |Max |Error |Throughput |etc.
When I use Write results to file/ Read form file filed , generated report will contain all http requests I generate, it can be millions. File would be huge and even then, no summary on the end . **No average time **
Same situation for aggregate report, I can not auto generate Summary of aggregate reports same as when you use GUI mode. Saved file contain all requests which is not useful at all.
Can I force Jmeter to save those two summaries when test is over ?
thanks in advance
First of all, don't run your test using GUI. Run your JMeter test using command-line non-GUI mode as
jmeter -n -t /path/to/testplan.jmx -l /path/to/results/jtl
Second, disable all the listeners during test run. Once test execution is finished you will be able to open JMeter's GUI, add Listener of your choice to Test Plan or Workbench and use "Browse" button to locate your results.jtl file.
JMeter cannot display only summary as all the "Total" fields are being calculated.
№ Samples - is count of all executed requests
Average - is arithmetical mean of all requests time (sum of all samples elapsed time divided by count)
etc. See JMeter Glossary for metrics explanation
So you got the idea right, it is better to store the necessary minimum, but you need to store something in order to be able to perform results analysis.
You can control what to store by amending properties which names start with jmeter.save.saveservice.. See jmeter.properties file in bin folder of your JMeter installation for the details.

Simulate millions of users with JMeter

I have a system that should be able to handle millions of users requests concurrently. In order to check how the system handles the load, I setup a cluster of JMeter servers (slaves), and one controller (client).
I have a database of all users (~10M), and I need each request sent to be from a different user.
I am wondering how I can implement such a thing in JMeter. Basically, I thought about dividing a range of users (let's say 100,000) per each slave, and then within a given slave, each request should read a new user from the local 100,000 list, and delete it. Thus, I will eventually send a request from every user.
The thing is while this idea sounds logical theoretically, I do not exactly know how to implement it using the JMeter terms. Also, I am not sure how to read from database in the test, although I could theoretically read it in advance into a text file, and have each slave contain the text file with its 100,000 users portion.
I can setup a very large cluster of machines, so scale will not be the issue here. Just how to set it all up.
The best way to provide Jmeter with a list of parameters is to use a CSV file:
http://jmeter.apache.org/usermanual/component_reference.html#CSV_Data_Set_Config
You can configure the CSV dataset config to do make every thread use a different line in the CSV. Each engine will need to have it’s own unique CSV file, because the sharing mode does nto work between engines in distributed testing (you can try to automate this part, this can be interesting to do :) ).
This is how your script should look like:
1. Thread Group
1.1 HTTP sampler (login)
1.1.1 CSV dataset config
1.2 second http sampler
etc...
The login sampler will use the parameters loaded by from the CSV file, so for every ’login’ it will use a different line.
Distributed testing is pretty simple:
http://jmeter.apache.org/usermanual/remote-test.html
Keep in mind that running 100K concurrent users on a single Jmeter load engine will be hard (Jmeter consumes resources on the server, so you will need lots of CPU and memory). So you should also monitor the engines.
Also 1M users will cause a lot of data that the engines will send back to the console, so you might need to start a bunch of distributed tests in parallel, and at the end aggregate the results.
Cheers,
This is can be implemented by doing the following steps:
Taking the user credential dump and saving it to a csv file
split the csv file. copy 1 file to each Jmeter slave, in the same location on all the
machines e.g. "C:\Loadtest\"
from the controller, give the path of your csv file in "CSV Data Set Config".
Run the Test.
By doing the above steps, Jmeter controller will start execution of the test by pointing all the Jmeter Slave nodes to use the CSV file in the same location "C:\Loadtest\".
But the trick here is that all the machine will be using different set of users.
Hope this will help.

Resources