/ erlang

HTTP Load testing with Tsung

After developing a web application we have to test performance. And regarding the result we need to improve the api.

Now lets see how we can test a restful api using Tsung.
Tsung is a erlang based application to test http, xmpp, mqtt or any other tcp, udp based protocol.

=> Installation instruction

Now create a configuration file to send load,

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE tsung SYSTEM "/usr/local/Cellar/tsung/1.7.0/share/tsung/tsung-1.0.dtd">
<tsung loglevel="warning">

    <client host="localhost" use_controller_vm="true"/>

    <server host="" port="9000" type="tcp"/>

    <arrivalphase phase="1" duration="1" unit="minute">
      <users arrivalrate="100" unit="second"/>

    <session name="dummy" weight="1" type="ts_http">
        <http url="/api/v1/product/list?page=0&amp;limit=4" method="GET" version="1.1" >

[+] change /usr/local/Cellar/tsung/1.7.0/share/tsung/tsung-1.0.dtd according to your system.

[+] change host and port as per your requirement.
In request

[+] change url to your api path.

[+] One thing to remember change & with &amp; otherwise it won't work and throw exception.

[+] For POST request put body in contents tag or contents_from_file="location_of_file". replace " with &quot;.

[+] add header by <http_header name="Referer" value="http://www.w3.org/"/> within http.

[+] set content type of body by content_type='application/json'

[+] Move to log directory and execute /usr/local/Cellar/tsung/1.7.0/lib/tsung/bin/tsung_stats.pl to generate static graph.

=> Documentation