processone / tsung

Tsung is a high-performance benchmark framework for various protocols including HTTP, XMPP, LDAP, etc.
http://www.process-one.net/en/tsung/
GNU General Public License v2.0
2.53k stars 405 forks source link

Tsung is failing to perform constant load #262

Open olka opened 6 years ago

olka commented 6 years ago

Recently I've started evaluating tsung and noticed that it's impossible to generate constant load to the server. According to documentation and this advice my configuration file looks like this:

<!DOCTYPE tsung SYSTEM "/usr/local/Cellar/tsung/1.7.0/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0">
  <clients>
    <client host="localhost" use_controller_vm="true" maxusers="999000" />
  </clients>

<servers>
  <server host="192.168.1.9" port="5050" type="tcp"/>
</servers>

   <load duration="250" unit="second">
    <arrivalphase phase="1" duration="200" unit="second"> 
    <users arrivalrate="900.0" unit="second"/> 
  </arrivalphase>
     </load>

 <sessions>
  <session name="tsung-benchmark" probability="100" type="ts_http">
    <request> <http url="/counter" method="GET" version="1.1"></http> </request>    
  </session>
 </sessions>
</tsung>

But results are totally inconsistent and rather showing bursty than constant load profile. Please also notice huge gap between load windows on server graph. Tsung results Server results OS: OSX 10.11.6 Tsung version 1.7.0

UPD: using instructions from this article I was able to produce somewhat constant load. But as you can see even those results are far from stable

Name highest 10s mean lowest 10s mean Highest Rate Mean Rate Mean Count
connect 37.34 sec 1.08 sec 206.9/sec 68.11/sec 7.03sec 18324
page 0.47 sec 0.23 sec 7375/sec 4757.57/sec 0.34sec 872659
request 0.47 sec 0.23 sec 7375/sec 4757.57/sec 0.34sec 872659
session 2mn 18sec 20.74 sec 151.7/sec 58.82/sec 1mn 24sec 10000
nniclausse commented 6 years ago

You are not using Tsung as it was designed for (simulate complex sessions, and run many in parallel) If you only want to send very quickly many requests to a single url, you should start a single session (or a few) and use a loop in this session. Creating a new session is much more expensive for Tsung than sending a new request inside a session. 900 new sessions / sec is quite a lot for a single node.

olka commented 6 years ago

Thanks for the answer @nniclausse! It makes perfect sense from the results that I'm seeing at the moment. But the only drawback in your solution is that it's impossible to specify arrival rate in a loop. So I'm still confused what would be the best way to generate constant load without huge spikes and gaps (let's say 3000 rps)?

tisba commented 6 years ago

Why do arrival rate and looping exclude each other, @olka?

If you want to hit ~3k rps, you can let sessions loop (even forever) and add 100 clients per second up to 3000 clients.

In the loop you do a request then wait for ~1 sec.

After 30 seconds, you have done your ramp up and should reach your desired throughput.

eleschynskyy commented 6 years ago

@tisba , cld you please clarify re looping? here 2 kinds of looping have been mentioned: loop attribute inside load-section and "for" within "session". According to the answer there: "Loop on load section will generate new users". I got confused.. From one side according to official documentation if I want to produce classical "ramp up period" + "static load" possibly I have to specify:

But from other side according to provided answer re loop logic inside load section I MUST specify it as well in order to have users accumulated. B/c formally w/o "loop" it looks like constant load w/o accumulation of the users.

tisba commented 6 years ago

I'm not sure I follow. But I can try it :)

Every user launched in tsung run to completion (unless the test gets aborted). That said, if you let a user loop inside the session, it will be active for ever (or the test aborts).

You only need one arrival phase. In this phase you define your arrival rate and maxusers. To limit the overall test duration, you can use <load duration="1" unit="hour"> (see http://tsung.erlang-projects.org/user_manual/conf-load.html#duration-of-the-load-test).

Let's say you want to have 3000 users, a ramp up time of 5 minutes and a total test duration of 1 hour (note that the arrival phase is 6 minutes, that is to ensure that all 3000 users get launched; tsung's arrival rates are probabilistic):

<load duration="1" unit="hour">
  <arrivalphase phase="1" duration="6" unit="minute">
    <users interarrival="600" unit="minute" maxnumber="3000"></users>
  </arrivalphase>
</load>

In your session you can use this:

<session name="loop-forever" type="ts_http" probability="100">
  <for var="counter" from="1" to="2" incr="0">
    <request>
      <http url='/hello' version='1.1' method='GET' />
    </request>
  </for>
</session>
tisba commented 6 years ago

And maybe this also helps: http://tsung.erlang-projects.org/user_manual/faq.html#how-can-i-simulate-a-fix-number-of-users

tisba commented 6 years ago

Hey @olka. Are you still having issues?