SlideShare a Scribd company logo
Easy distributed load test with Tsung




                               Ngoc Dao
Source code:

     https://github.com/ngocdaothanh/tsart




                    Full doc:

http://tsung.erlang-projects.org/user_manual.html
Agenda
●   Install Tsung
●   Load test from one machine
●   Distributed load test
●   Test WebSocket
Install Tsung
How to install Tsung
1. Install Erlang
2. Install Tsung
                       Tsung is a program
                       written in Erlang language
                       (Erlang presentation next time)
Install Erlang
sudo yum install yum install gcc
                                                    For connecting to
sudo yum install openssl-devel                       other machines
                                                     to do distributed
sudo yum install ncurses-devel                    load test (later slides)


wget http://www.erlang.org/download/otp_src_R15B01.tar.gz
tar xzf otp_src_R15B01.tar.gz
                                    For Erlang
cd otp_src_R15B01                  command line



./configure –prefix=$HOME/opt/erlang-R15B01
make install

          http://www.erlang.org/download.html
Install Tsung
export PATH=$PATH:$HOME/opt/erlang-R15B01/bin


wget http://tsung.erlang-projects.org/dist/tsung-1.4.2.tar.gz
tar xzf tsung-1.4.2.tar.gz
cd tsung-1.4.2                         Need “erlc” command
                                         to compile Tsung

./configure –prefix=$HOME/opt/tsung-1.4.2
make install


export PATH=$PATH:$HOME/opt/tsung-1.4.2/bin



         http://tsung.erlang-projects.org/dist/
Load test from one machine
share/doc/tsung/examples




                                                                Load test
                                        (2)                      target
                                      Requests
test.xml                                       (3)
                (1)       Tsung             Responses



                            (4)


                                            lib/tsung/bin/tsung_stats.pl


                         Reports       sudo yum install gnuplot
                                       sudo cpan Template
To be able to create many
                  connections
●   Each connection is seen as an open file; default limit:
    Linux: limit -n => 1024
    Mac: launchctl limit => 256
●   Linux:
    Edit /etc/security/limits.conf:
    *        soft      nofile    1000000
    *        hard      nofile    1000000
●   Mac:
    sudo launchctl limit maxfiles 1000000 1000000

    Or create /etc/launchd.conf:
    limit maxfiles 1000000 1000000
●   More info on tuning:
    http://ngocdaothanh.github.com/xitrum/guide/deploy
test.xml


  https://github.com/ngocdaothanh/tsart/blob/master/single.xml


Pitfall:
<!DOCTYPE tsung SYSTEM "path/to/tsung-1.0.dtd">

The path must be correct.
Be careful if you copy the XML file from other machines.
Bypassing 30k limit
Each IP can only create about 25 thousands
connections. To bypass this problem:
  1. Create multiple IPs for one network interface
  2. Set "ports_range" option


http://tsung.erlang-projects.org/user_manual.html
http://lists.process-one.net/pipermail/tsung-users/2010-Oct
<load>...</load>

<options>
 <option name="ports_range" min="1025" max="65535"/>
</options>

<sessions>...</sessions>
Demo
●   Run test:
    tsung-1.4.2/bin/tsung -f test.xml -l . start
●   See status during test:
    tail -f tsung_controller.log
    tsung-1.4.2/bin/tsung status
●   Create reports:
    perl tsung-1.4.2/lib/tsung/bin/tsung_stats.pl
Distributed load test
Tsung
                                    worker


                                    Tsung
test.xml          Tsung                           (3)           Target
           (1)                (2)   worker
                 controller


                                    Tsung
                                    worker
                    (4)




                                      EC2 is very convenient!
                 Reports
test.xml
https://github.com/ngocdaothanh/tsart/blob/master/distributed.xml

  <clients>
    <!-- Must be hostname, can't be IP -->
    <client host="t1" cpu="8" maxusers="200000"/>
    <client host="t2" cpu="8" maxusers="200000"/>
    <client host="t3" cpu="8" maxusers="200000"/>
  </clients>


                    Distributed test is easy:
                     Just add more clients
(1)
                           ssh machine2 erl
                               (port: 22)
    Tsung                                                     Tsung
  controller                      (2)                         worker
(Erlang node)         Erlang node – Erlang node           (Erlang node)
 machine1              standard communication               machine2
                         (port: 4369 and ???)




                          http://linux.die.net/man/1/epmd
            http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html
Should not be 127.0.0.1
  =>
● /etc/hosts on t1:

  <ip1> t1
  <ip2> t2
  <ip3> t3
● /etc/hosts on t2, t3:

  <ip1> t1
=>
● Add erl to PATH:

  sudo echo 'pathmunge
  /home/ngoc/opt/erlang-R15B01/bin' >
  /etc/profile.d/erlang.sh

  sudo chmod +x /etc/profile.d/erlang.sh
● Or edit /etc/environment:

  PATH=”/home/ngoc/opt/erlang-R15B01/bin...”
Install once, copy everywhere
Basically, you only have to install on one
machine, then copy to others:
●   /etc/hosts
●   /etc/environment
●   /etc/sysctl.conf
●   /etc/security/limits.conf
●   Erlang
●   Tsung
Confirm
From the controller machine (t1):
ssh t1 erl
ssh t2 erl                                         Pitfall:
                                             Remember to run
ssh t3 erl                              this command to confirm,
                                                if you use
ssh localhost erl                   <client host="localhost"/>



Trouble shooting:
http://tsung.erlang-projects.org/user_manual.html
> Frequently Asked Questions
Demo
Test WebSocket


This one is good:
https://github.com/onlychoice/tsung/tree/websocket

This one may be better:
https://github.com/wulczer/tsung_ws
Example
https://github.com/wulczer/tsung_ws/blob/master/websocket.xml
Pitfall
●   I installed tsung-1.4.2 on t1, t2, t3. Then installed
    tsung-1.4.2-with-websocket-plugin on t1, but forgot to
    install it on t2 and t3.
    =>
    Install same version of Erlang and Tsung on all
    machines, at same paths
●   Tsung by default only creates 800 connections on
    each Erlang VM. It will spawn more Erlang nodes to
    create more connections. But Tsung will stop working
    when there are too many nodes (~100)
    =>
    Set maxusers to a large number (~200K/client).
<clients>
  <client host="t1" cpu="8" maxusers="200000">
    <ip scan="true" value="eth0"/>
  </client>
</clients>
Amazon EC2
●   Good: There is no Data Transfer charge between Amazon EC2
    and other Amazon Web Services within the same region
    http://aws.amazon.com/ec2/pricing/
    => Use private DNS address or IP instead of public ones
●
    m1.xlarge can create about 200 new connections/s
●
    Use Amazon VPC (Virtual Private Cloud) feature to create multiple
    virtual IPs for one network interface
●
    Pitfall: IP addresses of machines change after each restart =>
    Need to update /etc/hosts of the controller machine
Easy distributed load test with Tsung
Easy distributed load test with Tsung
Bypassing 30k limit on EC2
1. Create VPC
2. Use admin page to add instance to the VPC
3. Use admin page to add virtual IPs
4. Assign virtual IPs to network inteface eth0
5. Confirm
MAC_ADDR=$(ifconfig eth0 | sed -n
's/.*HWaddr ([a-f0-9:]*).*/1/p')

IP=($(curl http://169.254.169.254/latest/meta-
data/network/interfaces/macs/$MAC_ADDR/local-
ipv4s))

for ip in ${IP[@]:1}; do
     echo "Adding IP: $ip"
     sudo ip addr add dev eth0 $ip/24
done

ip addr show

http://about.silkapp.com/page/Multiple%20IP%20addresses%2
More topics
●   tsung-recorder:
    Use normal browsers to create test.xml
●   tsplot:
    Merge various tsung_stats.pl graphs into one
●   Monitoring:
    Erlang, SNMP, Munin
●   Loops, variables etc.

http://tsung.erlang-projects.org/user_manual.html

More Related Content

PPT
C Basics
PPT
Python Part 1
PDF
Javascript Módulo 7 - PROFUNDIZACIÓN EN ARRAYS, OBJETOS, PROPIEDADES, MÉTODOS...
PPT
Collections Framework
PPTX
Machine learning ( Part 3 )
PPTX
Machine learning ( Part 2 )
PPT
生態復育與棲地營造
PPT
The Php Life Cycle
C Basics
Python Part 1
Javascript Módulo 7 - PROFUNDIZACIÓN EN ARRAYS, OBJETOS, PROPIEDADES, MÉTODOS...
Collections Framework
Machine learning ( Part 3 )
Machine learning ( Part 2 )
生態復育與棲地營造
The Php Life Cycle

What's hot (7)

PDF
Curso de Java: Introdução a lambda e Streams
PPTX
Pytest KT.pptx
PPTX
Java - Sockets
PPTX
Introduccion a la poo
PPT
Python part2 v1
PPTX
PHP Presentation
PDF
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
Curso de Java: Introdução a lambda e Streams
Pytest KT.pptx
Java - Sockets
Introduccion a la poo
Python part2 v1
PHP Presentation
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
Ad

Similar to Easy distributed load test with Tsung (20)

PDF
Tsung Intro presentation 2013
PDF
Erlang, the big switch in social games
PDF
Erlang factory SF 2011 "Erlang and the big switch in social games"
PDF
Tsung info
PDF
Erlang factory 2011 london
PDF
Designing for Scale
PDF
Magic Clusters and Where to Find Them - Eugene Pirogov
PDF
Distributed Erlang Systems In Operation
PDF
Magic Clusters and Where to Find Them 2.0 - Eugene Pirogov
PDF
Scaling to Millions of Simultaneous Connections by Rick Reed from WhatsApp
PDF
Whatsapp's Architecture
PDF
EUC2015 - Load testing XMPP servers with Plain Old Erlang
PDF
Introduction to Erlang Part 2
PDF
Egearmand: an Erlang Gearman daemon
PPTX
Cloud Erlang
PPTX
Vagrant, Ansible, and OpenStack on your laptop
PDF
Erlang Message Passing Concurrency, For The Win
KEY
WebSocket - Nov 2011
DOCX
Component pack 6006 install guide
PDF
SE2016 Exotic Valerii Vasylkov "Erlang. Measurements and benefits"
Tsung Intro presentation 2013
Erlang, the big switch in social games
Erlang factory SF 2011 "Erlang and the big switch in social games"
Tsung info
Erlang factory 2011 london
Designing for Scale
Magic Clusters and Where to Find Them - Eugene Pirogov
Distributed Erlang Systems In Operation
Magic Clusters and Where to Find Them 2.0 - Eugene Pirogov
Scaling to Millions of Simultaneous Connections by Rick Reed from WhatsApp
Whatsapp's Architecture
EUC2015 - Load testing XMPP servers with Plain Old Erlang
Introduction to Erlang Part 2
Egearmand: an Erlang Gearman daemon
Cloud Erlang
Vagrant, Ansible, and OpenStack on your laptop
Erlang Message Passing Concurrency, For The Win
WebSocket - Nov 2011
Component pack 6006 install guide
SE2016 Exotic Valerii Vasylkov "Erlang. Measurements and benefits"
Ad

More from Ngoc Dao (20)

PDF
Model with actors and implement with Akka
PPTX
I18nize Scala programs à la gettext
PDF
Develop realtime web with Scala and Xitrum
PDF
BIG DATA サービス と ツール
PDF
How to write a web framework
PDF
Xitrum @ Scala Matsuri Tokyo 2014
PPTX
Actor-based concurrency and Akka Fundamentals
PDF
Xitrum HOWTOs
ODP
Xitrum @ Scala Conference in Japan 2013
ODP
SockJS Intro
ODP
How to start using Scala
PPTX
Xitrum internals
PPT
Những lỗi bảo mật web thường gặp ở phần application
PPT
Erlang Web
PPT
Nitrogen Web Framework
PDF
スポイトができるまで
PDF
Camellia General
PPT
Nhập môn BDD
PPT
何でRuby
PDF
Sinh hoat CLB tin hoc Komaba lan 2 - Phat bieu cua Ngoc
Model with actors and implement with Akka
I18nize Scala programs à la gettext
Develop realtime web with Scala and Xitrum
BIG DATA サービス と ツール
How to write a web framework
Xitrum @ Scala Matsuri Tokyo 2014
Actor-based concurrency and Akka Fundamentals
Xitrum HOWTOs
Xitrum @ Scala Conference in Japan 2013
SockJS Intro
How to start using Scala
Xitrum internals
Những lỗi bảo mật web thường gặp ở phần application
Erlang Web
Nitrogen Web Framework
スポイトができるまで
Camellia General
Nhập môn BDD
何でRuby
Sinh hoat CLB tin hoc Komaba lan 2 - Phat bieu cua Ngoc

Recently uploaded (20)

PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Encapsulation theory and applications.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Machine learning based COVID-19 study performance prediction
PDF
Empathic Computing: Creating Shared Understanding
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Chapter 3 Spatial Domain Image Processing.pdf
Understanding_Digital_Forensics_Presentation.pptx
Unlocking AI with Model Context Protocol (MCP)
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Digital-Transformation-Roadmap-for-Companies.pptx
Encapsulation theory and applications.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Dropbox Q2 2025 Financial Results & Investor Presentation
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Agricultural_Statistics_at_a_Glance_2022_0.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation_ Review paper, used for researhc scholars
“AI and Expert System Decision Support & Business Intelligence Systems”
MYSQL Presentation for SQL database connectivity
Machine learning based COVID-19 study performance prediction
Empathic Computing: Creating Shared Understanding

Easy distributed load test with Tsung

  • 1. Easy distributed load test with Tsung Ngoc Dao
  • 2. Source code: https://github.com/ngocdaothanh/tsart Full doc: http://tsung.erlang-projects.org/user_manual.html
  • 3. Agenda ● Install Tsung ● Load test from one machine ● Distributed load test ● Test WebSocket
  • 5. How to install Tsung 1. Install Erlang 2. Install Tsung Tsung is a program written in Erlang language (Erlang presentation next time)
  • 6. Install Erlang sudo yum install yum install gcc For connecting to sudo yum install openssl-devel other machines to do distributed sudo yum install ncurses-devel load test (later slides) wget http://www.erlang.org/download/otp_src_R15B01.tar.gz tar xzf otp_src_R15B01.tar.gz For Erlang cd otp_src_R15B01 command line ./configure –prefix=$HOME/opt/erlang-R15B01 make install http://www.erlang.org/download.html
  • 7. Install Tsung export PATH=$PATH:$HOME/opt/erlang-R15B01/bin wget http://tsung.erlang-projects.org/dist/tsung-1.4.2.tar.gz tar xzf tsung-1.4.2.tar.gz cd tsung-1.4.2 Need “erlc” command to compile Tsung ./configure –prefix=$HOME/opt/tsung-1.4.2 make install export PATH=$PATH:$HOME/opt/tsung-1.4.2/bin http://tsung.erlang-projects.org/dist/
  • 8. Load test from one machine
  • 9. share/doc/tsung/examples Load test (2) target Requests test.xml (3) (1) Tsung Responses (4) lib/tsung/bin/tsung_stats.pl Reports sudo yum install gnuplot sudo cpan Template
  • 10. To be able to create many connections ● Each connection is seen as an open file; default limit: Linux: limit -n => 1024 Mac: launchctl limit => 256 ● Linux: Edit /etc/security/limits.conf: * soft nofile 1000000 * hard nofile 1000000 ● Mac: sudo launchctl limit maxfiles 1000000 1000000 Or create /etc/launchd.conf: limit maxfiles 1000000 1000000
  • 11. More info on tuning: http://ngocdaothanh.github.com/xitrum/guide/deploy
  • 12. test.xml https://github.com/ngocdaothanh/tsart/blob/master/single.xml Pitfall: <!DOCTYPE tsung SYSTEM "path/to/tsung-1.0.dtd"> The path must be correct. Be careful if you copy the XML file from other machines.
  • 13. Bypassing 30k limit Each IP can only create about 25 thousands connections. To bypass this problem: 1. Create multiple IPs for one network interface 2. Set "ports_range" option http://tsung.erlang-projects.org/user_manual.html http://lists.process-one.net/pipermail/tsung-users/2010-Oct
  • 14. <load>...</load> <options> <option name="ports_range" min="1025" max="65535"/> </options> <sessions>...</sessions>
  • 15. Demo ● Run test: tsung-1.4.2/bin/tsung -f test.xml -l . start ● See status during test: tail -f tsung_controller.log tsung-1.4.2/bin/tsung status ● Create reports: perl tsung-1.4.2/lib/tsung/bin/tsung_stats.pl
  • 17. Tsung worker Tsung test.xml Tsung (3) Target (1) (2) worker controller Tsung worker (4) EC2 is very convenient! Reports
  • 18. test.xml https://github.com/ngocdaothanh/tsart/blob/master/distributed.xml <clients> <!-- Must be hostname, can't be IP --> <client host="t1" cpu="8" maxusers="200000"/> <client host="t2" cpu="8" maxusers="200000"/> <client host="t3" cpu="8" maxusers="200000"/> </clients> Distributed test is easy: Just add more clients
  • 19. (1) ssh machine2 erl (port: 22) Tsung Tsung controller (2) worker (Erlang node) Erlang node – Erlang node (Erlang node) machine1 standard communication machine2 (port: 4369 and ???) http://linux.die.net/man/1/epmd http://www.erlang.org/doc/apps/erts/erl_dist_protocol.html
  • 20. Should not be 127.0.0.1 => ● /etc/hosts on t1: <ip1> t1 <ip2> t2 <ip3> t3 ● /etc/hosts on t2, t3: <ip1> t1
  • 21. => ● Add erl to PATH: sudo echo 'pathmunge /home/ngoc/opt/erlang-R15B01/bin' > /etc/profile.d/erlang.sh sudo chmod +x /etc/profile.d/erlang.sh ● Or edit /etc/environment: PATH=”/home/ngoc/opt/erlang-R15B01/bin...”
  • 22. Install once, copy everywhere Basically, you only have to install on one machine, then copy to others: ● /etc/hosts ● /etc/environment ● /etc/sysctl.conf ● /etc/security/limits.conf ● Erlang ● Tsung
  • 23. Confirm From the controller machine (t1): ssh t1 erl ssh t2 erl Pitfall: Remember to run ssh t3 erl this command to confirm, if you use ssh localhost erl <client host="localhost"/> Trouble shooting: http://tsung.erlang-projects.org/user_manual.html > Frequently Asked Questions
  • 24. Demo
  • 25. Test WebSocket This one is good: https://github.com/onlychoice/tsung/tree/websocket This one may be better: https://github.com/wulczer/tsung_ws
  • 27. Pitfall ● I installed tsung-1.4.2 on t1, t2, t3. Then installed tsung-1.4.2-with-websocket-plugin on t1, but forgot to install it on t2 and t3. => Install same version of Erlang and Tsung on all machines, at same paths ● Tsung by default only creates 800 connections on each Erlang VM. It will spawn more Erlang nodes to create more connections. But Tsung will stop working when there are too many nodes (~100) => Set maxusers to a large number (~200K/client).
  • 28. <clients> <client host="t1" cpu="8" maxusers="200000"> <ip scan="true" value="eth0"/> </client> </clients>
  • 29. Amazon EC2 ● Good: There is no Data Transfer charge between Amazon EC2 and other Amazon Web Services within the same region http://aws.amazon.com/ec2/pricing/ => Use private DNS address or IP instead of public ones ● m1.xlarge can create about 200 new connections/s ● Use Amazon VPC (Virtual Private Cloud) feature to create multiple virtual IPs for one network interface ● Pitfall: IP addresses of machines change after each restart => Need to update /etc/hosts of the controller machine
  • 32. Bypassing 30k limit on EC2 1. Create VPC 2. Use admin page to add instance to the VPC 3. Use admin page to add virtual IPs 4. Assign virtual IPs to network inteface eth0 5. Confirm
  • 33. MAC_ADDR=$(ifconfig eth0 | sed -n 's/.*HWaddr ([a-f0-9:]*).*/1/p') IP=($(curl http://169.254.169.254/latest/meta- data/network/interfaces/macs/$MAC_ADDR/local- ipv4s)) for ip in ${IP[@]:1}; do echo "Adding IP: $ip" sudo ip addr add dev eth0 $ip/24 done ip addr show http://about.silkapp.com/page/Multiple%20IP%20addresses%2
  • 34. More topics ● tsung-recorder: Use normal browsers to create test.xml ● tsplot: Merge various tsung_stats.pl graphs into one ● Monitoring: Erlang, SNMP, Munin ● Loops, variables etc. http://tsung.erlang-projects.org/user_manual.html