Friday, September 18, 2015

Why the # of Threads in .jtl file are not matching with the actual threads count when using JMeter Distributed testing?



When we using JMeter Remote testing, more than one slave machines are running the same tests and the test results from all of the slave machines will record in the client machine. Aggregate.jtl file will save all of the test results and we can analyze the results from the .jtl file information. But I found one more issue at here.  The number of threads (Virtual Users) is not matching what we expect. For example,
We have 2 slave machines to run our test; each slave machine will run 100 threads, so we totally use 200 threads.  And after we run the remote tests in the two slave machine, we saw 200 samples but only 100 thread records in the .jtl file, rather than 200 samples and 200 threads.
 Why? 
This is because the 2 slave machines running the exactly the same test with the exact same Thread Group Name, so in the .jtl file, they can’t figure out which thread group is coming from slave machine 1 or slave machine 2, so it thinks they have the same thread group name, so they are the same thread, rather than two different threads. 
How to solve this issue and make the .jtl result file have the correct thread number?
The solution is we need to let the thread group name is different and .jtl will know it comes from which slave machines.  So we need to change the thread group name from the static name to be a dynamic name with slave machine ip or name.  The functions ${__machineName()} and ${__machineIP()} are our key to solve the problem. 


 If you are doing distributed tests, you should name the thread groups like this in your test plan:

${__machineName()}_My Threadgroup name


Or

${__machineIP()}_My Threadgroup name
 


 
After modified the thread group name in the test plan, in the active threads over time listener, we can see each test thread in the test plan are records according to the running slave machines like this 


The follwing link is helping to fix my # of threads issue. :)

 



No comments:

Post a Comment