I often use JMeter to test web apps and web services – it is a great tool – easy to use (GUI based), java based (so runs on any platform), lots of function etc….

Now that most production level apps/services sit behind a load balancer (AWS ELB for example) JMeter will not really test all the servers behind the ELB without some configuration.  Why? Java DNS cache.  For load balancers that use a DNS based distrubution method (like round robin), your HTTP client makes a connection to the load balancer, and the load balancer says “hey use IP x.x.x.x”.  Your HTTP cleint then caches that ip for future requests.

This is not good when trying to test your load balanced app, as you will only be testing one of the nodes that is behind the load balancer.  To get around this in JMeter, just change the JVM dns ttl by passing a properties file to JMeter. Example:

 

$ cat test.properties 

networkaddress.cache.ttl=0
sun.net.inetaddr.ttl=0

 

Now run JMeter via:
jmeter -q test.properties -t test_plan.jmx 

 

Thats it!

 

 

Advertisements