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

I am using a php based web application on Ubuntu platform. I want to load test 1000 concurrent users for the login process. (assuming correct username and password, it will be directed to the home page).

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

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

      

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

Any hints would be much appreciated.

+3


source to share


2 answers


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



  • Basic HTTP Authentication
    You want the parameter to -A

    provide basic authentication credentials.

  • Cookie Based Authentication
    You want the parameter to provide the -C

    name and value of the cookie.

  • Forms Authentication Trigger
    You want the parameters -T

    and -p

    set the POST file and content type for this file. If it's a standard HTML form, the content type is likely to be application/x-www-form-urlencoded

    . The file will contain the login form field name / value pairs, encoded for form submission. Stack overflow response application / x-www-form-urlencoded or multipart / form-data? contains information on how to do this.

+6


source


You must use cookie based authentication. Login to your website using a browser and get the cookie name and value. From the linux console, run something like this:

ab -C PHPSESSID = h9s0r2hbpuf91vt7ulvnurp300 -l -r -n 100 -c 10 -k -H "Accept-Encoding: gzip, deflate" http: //localhost/some_path/your_page.php



From the documentation -C cookie-name = value Add cookie to the request: line. The argument is usually in the form of a name = value pair. This field is repeated.

+1


source







All Articles