How to Use the Static Hosting Feature in JMeter 3.2
Apache JMeter™ 3.2 was released and now enables Static Host Resolution through the DNS Cache Manager. This is a great change for users who need to load test servers that are not connected to a DNS Server or aren’t in our DNS Servers records yet. This blog post will explain what the DNS Cache Manager is, why Static Host Resolution is needed and how to use it. Please note that the DNS Cache Manager works with HttpClient4 only.
What is DNS?
Domain Name System (or Service or Server) is an Internet service that translates domain names into IP addresses. Because domain names are alphabetic, they're easier to remember. The Internet however, is based on IP addresses. Every time you use a domain name, a DNS service must translate the name into the corresponding IP address.
The DNS system is its own network. If one DNS server doesn't know how to translate a particular domain name, it asks another one, and so on, until the correct IP address is returned. In essence, DNS is a kind of database that matches meaningful host names, such as http://www.blazemeter.com, to a specific IP address, such as 188.8.131.52.
Load Testing with JMeter’s DNS Cache Manager
When load testing websites we might face issues with IP addresses. For example, large websites often have several IP addresses, but when running tests, requests go to only one single IP address. This means not all servers were load tested.
JMeter’s DNS Cache Manager was created to fix this problem. After configuring the test, including the server you want to test, add the DNS Cache Manager to the Test Plan. Then, enable the Custom DNS Resolver with the IP addresses that are already there. To learn how to work with the DNS Cache Manager, click here.
JMeter’s DNS Cache Manager significantly improves the testing of:
1. CDN (Content Delivery Networks) - Globally distributed network of proxy servers deployed in multiple data centers. The goal of a CDN is to serve content to end-users with high availability and high performance
2. DNS Load Balancing - The practice of configuring a domain in the Domain Name System (DNS) so that client requests to the domain are distributed across a group of server machines. A domain can correspond to a website, mail system, printer server, or any other service that is accessible via the Internet.
3. Load Balancers that have more than one entry IP addresses
DNS Cache Manager Issues
This all sounds great, but the DNS Cache Manager had a few critical issues. Mainly, the inability to load test servers that are not connected to a DNS Server or aren’t in our DNS Servers records yet.
Let’s say we have server named www.example.com and we want to reach it through the IP of the server other.example.org, which isn’t in our DNS Server records. This situation is rather common - there are many situations when two hosts works with different DNS, and there is no ability to make a connection between them immediately.
The first way to fix this is to change the hosts file on your workstation or server where you execute tests. This is the system text configuration file that maps hostnames to IP addresses. However, this is not great solution, since your scripts become machine specific, and each time you need to run your script on another machine, you will need to manually update the hosts file there. In addition, it is often impossible to change the file due to different system administration restrictions.
But there is a solution. To reach our goal, we can add an entry to the Static Host Table of the DNS Cache Manager.
Static Hosting in JMeter
Static Hosting lets us make our own DNS table, and choose which server we want to test. All we need to do here is to open our DNS Cache Manager window. In the “Options” block, check the “Use custom DNS resolver” button to fill in the necessary credentials in the table.
You can either put in the IP address of the server you want to check, or the Hostname of the server. In this case, type www.example.com in the “Host” field in the Static Host Table. Then, type other.example.org or the IP address of the test server in the second field, named “Hostname of IP address”.
This allows us to specify hosts for our custom DNS resolver, which maps the server domain we are testing to the IP/hostname we are trying to reach.
At the same time, if the system isn’t able to receive the test server’s IP address from the custom DNS server, it will search for it with the help of system DNS resolver. This process is automated by the DNS Cache Manager itself.
Now, if you use www.example.com in your HttpClient4 samplers, the requests will be made against other.example.org with all the headers set to www.example.com.
That’s it, you now know all necessary information about the new static hosting feature in JMeter 3.2. To learn more about JMeter check out this free webinar. To learn more about BlazeMeter, which enhances JMeter abilities, request a demo or put your URL or JMX file in the box below and your test will start in minutes.