skip to Main Content

I’m testing my load balancing server, where I have two machines as server and one machine as balancer. I want to know which machine fails at the end of the test and how many times. I request the same file in both servers which just contains “machine1” and “machine2”.

The load balancing algorithm used is round robin.

When I’m testing my server with JMeter I receive that body as “response data”, and I have created a regular expression(Regular expression Extractor) to try to count how many times I receive “Machine2” and “Machine1” but doesn’t work.

So at the end of 500 request for example, I want to know how many times Machine2 and Machine1 appears in that Responde data.

Can anyone help me?

Thank

2

Answers


  1. You can use Regular Expression Extractor as child of your request,

    Use Regular Expression for finding, with | as Or condition:

    machine1|machine2
    

    Use Template $1$ and put Match No. value as -1. created variable put machine for example

    This will save number of occurrences in special variable end with _matchNr so you can use:

    ${machine_matchNr}
    

    If the match number is set to a negative number, then all the possible matches in the sampler data are processed. The variables are set as follows:

    refName_matchNr – the number of matches found; could be 0

    Login or Signup to reply.
  2. The easiest way would be dynamically changing sampler name depending on response body.

    1. Add JSR223 PostProcessor as a child of your request
    2. Put the following code into “Script” area

      prev.setSampleLabel(prev.getResponseDataAsString())
      
    3. That’s it, the above script will substitute your sampler name with the response data, this way you will be able to figure out the number of samplers hitting this or that endpoint using listeners like Aggregate Report

    Demo:

    JMeter Demo Amend Sampler Name


    Don’t forget to add DNS Cache Manager to your test plan as in some cases JMeter can hit only one address due to caching of the DNS responses so all your load will go to a single host instead of being distributed across the cluster nodes

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search