使用Tsung进行Tigase负载测试。注册冲突409

时间:2015-07-28 10:22:08

标签: xmpp registration load-testing tsung tigase

我正在使用Tsung测试Tigase。

我的第一个测试脚本只是在Tigase服务器上注册用户。但是我有一个奇怪的问题是Tigase复制了一些用户ID的注册请求。

查看下面的tsung.dump文件。

用户43-tsung-user-2的注册请求重复两次。第一次成功,第二次Tigase返回冲突错误409,意味着用户已经注册。

NewClient:1438077277.663192:1
load:1
Send:1438077277.703507:<0.89.0>:<?xml version='1.0'?><stream:stream  id='1' to='ubuntu' xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams'>
Recv:1438077277.71206:<0.89.0>:<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='ubuntu' id='93e35376-1be1-413c-9285-2aa9558798d4' version='1.0' xml:lang='en'>
Recv:1438077277.717071:<0.89.0>:<stream:features><auth xmlns="http://jabber.org/features/iq-auth"/><register xmlns="http://jabber.org/features/iq-register"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism></mechanisms><ver xmlns="urn:xmpp:features:rosterver"/><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression></stream:features>
Send:1438077280.718581:<0.89.0>:<iq id='2' type='set' ><query xmlns='jabber:iq:register'><username>43-tsung-user1</username><resource>tsung</resource><password>pass1</password></query></iq>
Recv:1438077280.726568:<0.89.0>:<iq xmlns="jabber:client" type="result" id="2"/>
Send:1438077282.719153:<0.89.0>:</stream:stream>
EndClient:1438077282.719198:1
load:0
NewClient:1438077293.46312:1
load:1
Send:1438077293.4815:<0.94.0>:<?xml version='1.0'?><stream:stream  id='3' to='ubuntu' xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams'>
Recv:1438077293.484589:<0.94.0>:<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='ubuntu' id='4edaf8c7-72a5-48a0-99dc-33e6a348b838' version='1.0' xml:lang='en'>
Recv:1438077293.488533:<0.94.0>:<stream:features><auth xmlns="http://jabber.org/features/iq-auth"/><register xmlns="http://jabber.org/features/iq-register"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism></mechanisms><ver xmlns="urn:xmpp:features:rosterver"/><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression></stream:features>
Send:1438077296.490041:<0.94.0>:<iq id='4' type='set' ><query xmlns='jabber:iq:register'><username>43-tsung-user2</username><resource>tsung</resource><password>pass2</password></query></iq>
Recv:1438077296.502307:<0.94.0>:<iq xmlns="jabber:client" type="result" id="4"/>
Send:1438077298.496102:<0.94.0>:</stream:stream>
EndClient:1438077298.496152:2
load:0
NewClient:1438077303.492718:1
load:1
Send:1438077303.502446:<0.96.0>:<?xml version='1.0'?><stream:stream  id='5' to='ubuntu' xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams'>
Recv:1438077303.511868:<0.96.0>:<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='ubuntu' id='e3f918bc-e45d-4bb2-918d-62d85b93cec7' version='1.0' xml:lang='en'>
Recv:1438077303.515748:<0.96.0>:<stream:features><auth xmlns="http://jabber.org/features/iq-auth"/><register xmlns="http://jabber.org/features/iq-register"/><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism></mechanisms><ver xmlns="urn:xmpp:features:rosterver"/><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"/><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression></stream:features>
Send:1438077306.517646:<0.96.0>:<iq id='6' type='set' ><query xmlns='jabber:iq:register'><username>43-tsung-user2</username><resource>tsung</resource><password>pass2</password></query></iq>
Recv:1438077306.524358:<0.96.0>:<iq xmlns="jabber:client" type="error" id="6"><query xmlns="jabber:iq:register"><username>43-tsung-user2</username><resource>tsung</resource><password>pass2</password></query><error type="cancel" code="409"><conflict xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xml:lang="en" xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Unsuccessful registration attempt</text></error></iq>
Send:1438077308.520858:<0.96.0>:</stream:stream>
EndClient:1438077308.52091:3
load:0

我的测试需要30秒,用户间隔10秒。因此,应在数据库中创建3个用户。测试结束后,我只能看到2个用户,这也是tsung.dump所说的。

为什么tsung会重复请求某些用户?无论负载如何,Tsung的行为都相似。如果我提高负载数量,我将收到类似的行为。大多数情况下,成功注册用户的数量大约是tsung生成用户数的一半。

以下是我的tsung.xml

<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/Cellar/tsung/1.5.1/share/tsung/tsung-1.0.dtd”>    
<tsung loglevel="debug" version="1.0" dumptraffic="true">
      <clients>
          <client host="localhost" use_controller_vm="true" maxusers="100000"></client>
      </clients>
      <servers>
          <server host="192.168.100.133" port="5222" type="tcp" weight="1"></server>
      </servers>
    <load>
        <arrivalphase phase="1" duration="30" unit="second">
            <users maxnumber="100000" interarrival="10" unit="second"></users>
        </arrivalphase>
    </load>
    <options>
       <option type="ts_jabber" name="global_number" value="100000"></option>
       <option type="ts_jabber" name="userid_max" value="100000" />
       <option type="ts_jabber" name="domain" value="ubuntu"></option>
       <option type="ts_jabber" name="username" value="43-tsung-user"></option>
       <option type="ts_jabber" name="passwd" value="pass"></option>
    </options>
    <sessions>
      <session probability="100" name="jabber-example" type="ts_jabber">

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

        <thinktime value="3" random="false"></thinktime>

        <request>
          <jabber type="register" ack="no_ack" id="new"></jabber>
        </request>

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

        <request>
          <jabber type="close" ack="no_ack"></jabber>
        </request>

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

1 个答案:

答案 0 :(得分:1)

Tsung随机播放场景,并将重用一些用户ID。这意味着每次选择用户播放场景时,如果这是Tsung第二次使用用户ID,则存在冲突风险。

除非您希望专门加载测试客户端注册,否则我建议您直接在Tigase中预先创建用户库。这样,您就可以从您的场景中删除注册部分,避免注册冲突。