How to use Apache Benchmark (ab) to login to a site

Yash picture Yash · Aug 16, 2014 · Viewed 13.7k times · Source

I am running a php based web application in Ubuntu platform. I want to perform load testing to 1000 concurrent users for the login process. (when correct username and password are provided, it will be directed to the home page).

I am using Apache Benchmark (ab) to do the load testing. I used this command to load the login page alone.

    ab -n 1000 -c 1000 http://localhost/etsp/

How can I extend this command to test the login process? What I meant was, is there any way to provide username and password to this?

Any hint will be highly appreciated.

Answer

hrunting picture hrunting · Aug 16, 2014

Look at the man page for Apache Benchmark for the option that makes the most sense given your application:

  • HTTP Basic Authentication
    You want the -A option to supply basic authentication credentials.

  • Cookie-Based Authentication
    You want the -C option to supply the cookie name and value.

  • Form-based Authentication Trigger
    You want the -T and -p options to specify a POST file and content type for that file. If it's a standard HTML form, the content type is probably going to be application/x-www-form-urlencoded. The file is going to contain the login form field name/value pairs encoded for the form submission. The Stack Overflow answer application/x-www-form-urlencoded or multipart/form-data? has information about how to do this.