
W tym artykule opiszę jak prawidłowo zainstalowa, skonfigurować i uruchomić Tsunga celem przetestowania wydajności serwera Nginx.
Moje środowisko testowe składa się z trzech maszyn połączonych siecią bezprzewodową:
System operacyjny na każdej z nich to Kubuntu 7.10.
Na każdym komputerze plik /etc/hosts zawiera następujące wpisy:
192.168.1.4 akira 192.168.1.3 agony 192.168.1.118 amnezja
Rozpoczynamy instalację, najpierw erlang wraz ze środowiskiem do zbudowania paczki z tsungiem:
sudo apt-get install erlang build-essential fakeroot dh_make devscripts
następnie tsung (ze źródeł):
wget http://tsung.erlang-projects.org/dist/tsung-1.2.2.tar.gz tar -zxf tsung-1.2.2.tar.gz cd tsung-1.2.2 fakeroot debian/rules binary sudo dpkg -i ../tsung_1.2.2-1_all.deb
Jeśli po drodze nie pojawiły się komunikaty o błędach - mamy już zainstalowanego tsunga. Możemy sprawdzić to poleceniem:
[22:41:30] bluszcz@amnezja:~ $ tsung --help tsungstart|stop|restart|debug|status|recorder|stop_recorder|version [22:47:11] bluszcz@amnezja:~ $
Na pozostałych maszynach nie musimy powtarzać procedury budowania tsunga ze źródeł - wystarzy zainstalować erlanga i zbudowaną wcześniej paczkę z tsungiem.
Teraz tworzymy plik konfiguracyjny (na jednej ,centralne maszynie na której będzie uruchamiać tsunga - w moim przypadku jest to laptop amnezja):
mkdir -p $HOME/.tsung vim $_/agony.xml
Mój plik agony.xml wygląda nastęująco:
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0">
<!-- Client side setup -->
<clients>
<client host="localhost" maxusers="1200" cpu="2" />
<client host="akira" weight="3" maxusers="1200" cpu="2">
<ip value="192.168.1.4"></ip>
</client>
<client host="agony" weight="1" maxusers="600" cpu="1">
<ip value="192.168.1.3"></ip>
</client>
</clients>
<!-- Server side setup -->
<servers>
<server host="agony" port="80" type="tcp"></server>
</servers>
<!-- to start os monitoring (cpu, network, memory). Use an erlang
agent on the remote machine or SNMP. erlang is the default -->
<monitoring>
<monitor host="localhost" type="erlang"></monitor>
<monitor host="agony" type="erlang"></monitor>
<monitor host="akira" type="erlang"></monitor>
</monitoring>
<load>
<!-- several arrival phases can be set: for each phase, you can set
the mean inter-arrival time between new clients and the phase
duration -->
<arrivalphase phase="1" duration="1" unit="minute">
<users interarrival="0.1" unit="second"></users>
</arrivalphase>
</load>
<options>
<option type="ts_http" name="user_agent">
<user_agent probability="80">Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Galeon/1.3.21 Bluszcz</user_agent>
<user_agent probability="20">Mozilla/5.0 (Windows; U; Windows NT 5.2; fr-FR; rv:1.7.8) Gecko/20050511 Firefox/1.0.4 Bluszcz</user_agent>
</option>
</options>
<!-- start a session for a http user. the probability is the
frequency of this type os session. The sum of all session's
probabilities must be 100 -->
<sessions>
<session name='rec20080312-20:29' probability='100' type='ts_http'>
<request><http url='http://agony/munin/' version='1.0' method='GET'></http></request>
<request><http url='/munin/' version='1.0' method='GET'></http></request>
<request><http url='/munin/' version='1.0' method='GET'></http></request>
<request><http url='/munin/' version='1.0' method='GET'></http></request>
<request><http url='/munin/' version='1.0' method='GET'></http></request>
<request><http url='/munin/' version='1.0' method='GET'></http></request>
<request><http url='/munin/' version='1.0' method='GET'></http></request>
<request><http url='/munin/' version='1.0' method='GET'></http></request>
<request><http url='/munin/' version='1.0' method='GET'></http></request>
<request><http url='/munin/' version='1.0' method='GET'></http></request>
<request><http url='/munin/' version='1.0' method='GET'></http></request>
</session>
</sessions>
</tsung>
Kilka słów wyjaśnienia. Testowany będzie serwer nginx, a konkretnie główna strona munina - programu do monitorowania.
W tym momencie możemy rozpocząć testy:
[23:10:44] bluszcz@amnezja:~ $ tsung -f .tsung/agony.xml start Starting Tsung "Log directory is: /home/bluszcz/.tsung/log/20080315-22:10" [23:12:48] bluszcz@amnezja:~
Po zakończeniu testu wchodzi do katalogu z logami i generujemy raport:
[23:12:48] bluszcz@amnezja:~ $ cd /home/bluszcz/.tsung/log/20080315-22\:10/ [23:27:00] bluszcz@amnezja:~/.tsung/log/20080315-22:10 $ /usr/lib/tsung/bin/tsung_stats.pl creating subdirectory data creating subdirectory images creating subdirectory gnuplot_scripts warn, last interval (2) not equal to the first, use the first one (10) No data for Match No data for Event No data for Async No data for Errors [23:27:06] bluszcz@amnezja:~/.tsung/log/20080315-22:10 $ ls *html graph.html report.html [23:27:13] bluszcz@amnezja:~/.tsung/log/20080315-22:10
Przykładowe obrazki z raportów:
[img:1]
[img:2]
[img:3]
[img:4]
Ostatnie odpowiedzi
1 rok 35 tygodni temu
2 lata 24 tygodnie temu
2 lata 27 tygodni temu
2 lata 27 tygodni temu
2 lata 28 tygodni temu