Tuesday, 7 December 2010

Load testing Ejabberd XMPP Server with Tsung

In order to determine how many servers and what technology is required for a back end Jabber/XMPP server instance I used Tsung to complete a load test.

Tsung is another open source tool written in erlang. Tsung can be used to load test on multiple protocols, including HTTP, LDAP, PostgreSQL and Jabber/XMPP servers.

Tsung can be used to simulate real users and log them all in simultaneously, stress testing the scalability of your servers. For XMPP Tsung can test authentication, logins, chats, requests and much more.

Refer to http://tsung.erlang-projects.org/ for full details.

For initial install load Tsung on one client machine using the instructions below. The same tsung test can be run from multiple clients simultaneously in order to offer maximum stress testing.


1. wget http://tsung.erlang-projects.org/dist/tsung-1.3.3.tar.gz

2. extract the contents, e.g. to usr/local/share/tsung on ubuntu

3. run ./configure from inside the the tsung-1.3.3 folder
then make
make install

4. Run tsung from command prompt, the following should be displayed:

Usage: tsung start|stop|debug|status
Options:
    -f      set configuration file (default is ~/.tsung/tsung.xml)
    -l   set log file (default is ~/.tsung/log/YYYYMMDD-HH:MM/tsung.log)
    -i        set controller id (default is empty)
    -r   set remote connector (default is ssh)
    -s            enable erlang smp on client nodes
    -F            use long names (FQDN) for erlang nodes
    -v            print version information and exit
    -h            display this help and exit


You can simulate logins in a number of different way; for my benchmark test I initially created thousands of users within ejabberd using the following script:

for i in `seq 1 10000`; do echo $i && ejabberdctl register test$i servername password$i; done

This created 10000 users from test1 to test10000 with respective passwords.
These users can then be simulated by modifying the tsung.xml file usually located in ~/.tsung . Sample files for different test purposes are available at /usr/local/share/doc/tsung/examples/ . 
Configure this file to match whatever benchmarking criteria you require; whether it be load progressions or test duration, all these values can be specified here.


Full explanation of file structure is available in the tsung user manual
The file I used is similar to those in the samples, it made all users appear online simultaneously.

Some snippets from the tsung.xml file I used:

<clients>
     <client host="localhost" use_controller_vm="true" maxusers="100000"></client>

  </clients>

  <servers>
   <server host="serverIP" port="5222" type="tcp"></server>
  </servers>

<load>
    <arrivalphase phase="1" duration="1" unit="minute">
     <users maxnumber="10000" interarrival="0.001" unit="second"></users>
    </arrivalphase>
   </load>



<options>
   <option type="ts_jabber" name="global_number" value="10000"></option>
   <option type="ts_jabber" name="userid_max" value="100000"></option>
   <option type="ts_jabber" name="domain" value="server domain"></option>
   <option type="ts_jabber" name="username" value="test"></option>
   <option type="ts_jabber" name="passwd" value="password"></option>
  </options>

<sessions> 
<session probability="100" name="jabber-example" type="ts_jabber"
    

<request>
      <jabber type="connect" ack="local"></jabber>
    </request>


    <thinktime value="2"></thinktime>


 <transaction name="authenticate">

<request> <jabber type="auth_get" ack="local"></jabber></request>
    <request> <jabber type="auth_set_plain" ack="local"></jabber></request>
</transaction>

    <request>
      <jabber type="presence:initial" ack="global"></jabber></request>
    <thinktime value="6000"></thinktime>

<transaction name="close">
    <request> <jabber type="close" ack="local"></jabber></request>

</transaction>
  </session>
 </sessions>
</tsung>
</tsung>


To run the test execute tsung -f tsung.xml start . Ensuring tsung.xml points to your own configuration file.

N.B If you are testing large number of users you need to look at changing max values in /opt/ejabberd/conf/ejabberdctl.cfg on the server instance. There are a number of options that can be set here, the file explains what each value does.

See results and witness logons by accessing http://MYSERVER:5280/admin and viewing log files in ~/.tsung/log

Refer to Tsung User manual for full usage


Support posts and archives http://lists.jabber.ru/pipermail/ejabberd/

9 comments:

  1. Hi Lee,

    thanks a lot for this interesting post. Would it be possible to publish the entire tsung.xml file? Would be great!

    Cheers

    ReplyDelete
  2. could you please upload the tsung.xml file aswell

    ReplyDelete
  3. Hi Guys,

    It's been a while since I've posted this. I will see if I can dig out the relevant files and upload them.

    ReplyDelete
  4. hi there

    i want to test and benchmark my HTTP and XMPP server and compare the two results.

    do you have xml files and howto of HTTP v/s XMPP servers?

    ReplyDelete
  5. Hi,
    Are you aware of any tool to load test xmpp with TLS.I do not think tsung as starttls support.

    ReplyDelete
    Replies
    1. yeah, I agree with you.

      Delete
  6. All I ever see of tsung tutorials are snippets of configuration files, but I can't ever see what a complete, typical config file looks like...not even in their documentation.

    ReplyDelete
    Replies
    1. Exactly, I was searching for a xmpp chat code snippet

      Delete
  7. This helped me:
    http://tsung.readthedocs.io/en/latest/benchmark.html#jabber-xmpp

    ReplyDelete