JMeter – DNS Cache Manager
Most companies use Network Load Balancing as a strategy to ensure that sites are stable and reliable. This way they can ensure that their service will continue to function even in the event of unforeseen circumstances or failure. Such tests can be performed using JMeter and the “DNS Cache Manager” element, which allows testing applications with multiple servers behind load balancers, such as CDNs (Material Delivery Networks), when the user receives material from different IP addresses.
JMeter uses the JVM’s DNS cache by default. As a result, only one server in the cluster handles the demand. To ensure that the load balancer balances the workload correctly, the DNS Cache Manager element resolves each thread’s names individually during each iteration.
How to add ‘DNS Cache Manager’ in the JMeter script?
Follow the below steps:
- Select the ‘Test Plan’ node
- Right-click on the ‘Test Plan’ node
- Hover the mouse on ‘Add’
- Hover the mouse on Config Element
- Click ‘DNS Cache Manager’
What are the ‘DNS Cache Manager’ input fields?
1. Name: to name the element
2. Leave any comments random.
3. Every iteration, clear cache – When enabled, each thread’s DNS cache is cleared each time an iteration begins. If the DNS hostname matches an entry in the internal cache, DNS Cache Manager caches the DNS hostname and IP address pairs and returns the cache value. The cache is cleared at the beginning of the thread if this check box is selected.
4. Use the system’s DNS resolver: To find the hostname of each thread representing a virtual user, the DNS cache manager will contact the DNS servers specified in your operating system’s network settings. In this situation, you should override the network address. cache.TTL value and set it to “0” in the $JAVA_HOME/jre/lib/security/java.security file. (The default value of the attribute is “-1”, which means “forever”)
5. Implement a custom DNS resolver: You can choose one or more DNS servers from the list.
The DNS cache manager selects a random server for each call if more than one is offered, and works on a rotating basis.
The DNS servers specified in your operating system’s network settings will be used as the system’s DNS resolver if nothing else is specified.
6. IP Address or Hostname – A list of DNS servers that will be used during the test can be provided. The network configuration DNS is used if “Use custom DNS resolution” is checked and the “Hostname or IP address” field is left blank.
7. Add – to include a row in the DNS server table
8. Delete – to delete the chosen DNS server entry
Important tip:
• Do not make the DNS cache manager of a particular HTTP sample a secondary element. The Test Plan or a Thread Pool element must have DNS Cache Manager inserted as a child element.
• Only HTTP requests that use the HTTPClient4 implementation are supported by DNS Cache Manager.