Configure JMeter to Handle Dynamic IPs and Loadbalancer

Do you see errors in JMeter while executing the performance testing, but not see such errors if you access the website manually during the load testing? If yes, then, there is a possibility you have not properly configured your JMeter script. Let’s configure JMeter to Handle Dynamic IPs and Loadbalancer before putting the load on such website.
This will paint your report red which no one wants as these errors are not related to the Application Under Test (AUT).
If JMeter is not configured properly for such a website then, you may observe the following:

  1. The requests are getting redirected to only one server and the other server is sitting idle while doing the load testing of the website that has multiple servers to balance the requests using a load balancer.
  2. Errors like “Target server failed to respond” or “Your hostname could not be resolved to an IP address” in JMeter or “ Software caused connection abort recv failed”

Here is how the results will look like. See below screenshot and the response data.
Errors due to DNS caching

There are several reasons for this problem like insufficient hardware or generating unrealistic load, but if you think you are generating realistic load using decent hardware, but still getting those error then, Java DNS caching could causing the problem.
DNS Caching problem occurs if there is:

  • a load balancer (for example, CDN)
  • or, IPs are dynamic (for example, services hosted on AWS)


  1. Change the TTL, Java DNS Cache settings
  2. Or, add DNS Cache Manager in JMeter (from JMeter 2.12 the DNS Cache Manager has been included as a configuration element)

Before looking into the solution let us see, how is Java DNS caching related to this problem?
What Java does is, it caches the IP address against each domain name you access and the JVM default TTL is set to never re-resolve DNS names to IP addresses. This means that when the IP address for  resource changes, the application will be unable to connect to that resource until someone manually restarts the JVM so that the new IP addresses can be picked up. In these cases, it is vital that the TTL be configured to a shorter time period, like 60 seconds.

Option 1:
You can configure the TTL in the file, which is located in the directory %JRE%libsecurity. The configured value specifies the number of seconds that the JVM should cache a successful DNS name lookup. Here is an example that shows how to configure the TTL to 60 seconds.

Option 2:
Dzimitry Kashlach created the “DNS Cache Manager” which is available in JMeter 2.12 and later versions. DNS Cache Manager is bundled with JMeter you don’t have to add any additional jar file for this.

  1. Add “DNS Cache Manager” Thread Group or Test Plan
  2. Check “Clear cache each iteration”
  3. It’s done

Find more information about DNS Cache Manager

Leave a Reply

Contact Us
close slider
Contact Us

How can we help you with?