Abdulkareem Mohammed
Abdulkareem Mohammed

Reputation: 139

Is there be a difference between ab testing on localhost and hostname?

I test my website using ab as ab -n 10000 -c 1000 http://example.com/path and I got response as 160 #/second. But when i test it as ab -n 10000 -c 1000 http://localhost/path the response is totally different 1500 #/second. why?

Upvotes: 1

Views: 1773

Answers (2)

Jerome L
Jerome L

Reputation: 637

From what I understand, you are testing the same website in 2 different configurations:

  • http://example.com/path, which is testing the remote website from your local computer,
  • http://localhost/path, which is testing the a local copy of website on your local machine, or being tested directly in the machine where the website is hosted.

Testing your remote website involves the network connection between your computer and the remote server. when testing locally, all the goes through the loopback network interface which is probably several orders of magnitude faster than your DSL internet connection.

Upvotes: 1

Dmitri T
Dmitri T

Reputation: 168002

Normally you should not be running load generator (ab or any other tool) on the same host where application under test lives as load testing tools themselves are very resource intensive and you may run into the situation when application under test and load generator are struggling for the same CPU, RAM, Network, Disk, Swap, etc.

So I would recommend running ab from another host in your intranet, this way you will be able to get more clear results without aforementioned mutual interference. Remember to monitor baseline OS health metrics using vmstat, iostat, top, sar, etc. on both application under test and load generator side - it should give you more clear picture regarding what's going on and what is the impact of the perceived load.

You may also want to try out a more advanced tool as ab has quite limited load testing capabilities, check out Open Source Load Testing Tools: Which One Should You Use? article for more information on the most prominent free and open source load testing solutions (all listed tools are cross-platform so you will be able to run them on Linux)

Upvotes: 2

Related Questions