简体   繁体   English

JMeter中的并发

[英]Concurrency in JMeter

I have a query regarding concurrency and constant throughput in JMeter. 我在JMeter中有一个关于并发性和恒定吞吐量的查询。 Could you please help me with this? 你能帮我这个忙吗?

Say I have a simple JMeter script to test a Rest api(get) and different JMeter parameters are set as follows. 假设我有一个简单的JMeter脚本来测试Rest api(get),并且不同的JMeter参数设置如下。

Number of threads(users)= 5,
Duration = 600 sec(10 minutes), 
Ramp up             = 1 sec

Constant throughput timer 恒定吞吐量计时器

Target throughput=5 per minute,
Calculate throughput based on=all active threads in the current thread group.

Assumption : Api responded instantaneously without any delay. 假设:Api立即做出响应,没有任何延迟。

Question

My understanding regarding JMeter is as follows: if I execute the script then JMeter will trigger 5 get requests concurrently (since the number of threads is set as 5) and then JMeter will wait for one minute (since the throughput is set as 5 per minute and JMeter has already triggered 5 request concurrently) and then again trigger 5 requests concurrently and this will continue for 600 seconds. 我对JMeter的理解如下:如果我执行脚本,则JMeter将并发触发5个get请求(因为线程数设置为5),然后JMeter将等待一分钟(因为吞吐量设置为每分钟5个)。并且JMeter已同时触发5个请求),然后再次同时触发5个请求,此过程将持续600秒。 Is my understanding correct? 我的理解正确吗?

Thanks in Advance 提前致谢

=========================== JMX file Starts================================ ====================================================================== ============

<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.9" jmeter="3.0 r1743807">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread" enabled="true">
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <intProp name="LoopController.loops">-1</intProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">5</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        <longProp name="ThreadGroup.start_time">1472550371000</longProp>
        <longProp name="ThreadGroup.end_time">1472550371000</longProp>
        <boolProp name="ThreadGroup.scheduler">true</boolProp>
        <stringProp name="ThreadGroup.duration">600</stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Sampler" enabled="true">
          <boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
          <elementProp name="HTTPsampler.Arguments" elementType="Arguments">
            <collectionProp name="Arguments.arguments">
              <elementProp name="" elementType="HTTPArgument">
                <boolProp name="HTTPArgument.always_encode">false</boolProp>
                <stringProp name="Argument.value"></stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
              </elementProp>
            </collectionProp>
          </elementProp>
          <stringProp name="HTTPSampler.domain">reqres.in</stringProp>
          <stringProp name="HTTPSampler.port"></stringProp>
          <stringProp name="HTTPSampler.connect_timeout"></stringProp>
          <stringProp name="HTTPSampler.response_timeout"></stringProp>
          <stringProp name="HTTPSampler.protocol">https</stringProp>
          <stringProp name="HTTPSampler.contentEncoding"></stringProp>
          <stringProp name="HTTPSampler.path">/api/users/2</stringProp>
          <stringProp name="HTTPSampler.method">GET</stringProp>
          <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
          <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
          <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
          <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
          <boolProp name="HTTPSampler.monitor">false</boolProp>
          <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
        </HTTPSamplerProxy>
        <hashTree>
          <ConstantThroughputTimer guiclass="TestBeanGUI" testclass="ConstantThroughputTimer" testname="Constant Throughput Timer" enabled="true">
            <intProp name="calcMode">2</intProp>
            <doubleProp>
              <name>throughput</name>
              <value>5.0</value>
              <savedValue>0.0</savedValue>
            </doubleProp>
          </ConstantThroughputTimer>
          <hashTree/>
        </hashTree>
      </hashTree>
      <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="Listner" enabled="true">
        <boolProp name="ResultCollector.error_logging">false</boolProp>
        <objProp>
          <name>saveConfig</name>
          <value class="SampleSaveConfiguration">
            <time>true</time>
            <latency>true</latency>
            <timestamp>true</timestamp>
            <success>true</success>
            <label>true</label>
            <code>true</code>
            <message>true</message>
            <threadName>true</threadName>
            <dataType>true</dataType>
            <encoding>false</encoding>
            <assertions>true</assertions>
            <subresults>true</subresults>
            <responseData>false</responseData>
            <samplerData>false</samplerData>
            <xml>true</xml>
            <fieldNames>false</fieldNames>
            <responseHeaders>false</responseHeaders>
            <requestHeaders>false</requestHeaders>
            <responseDataOnError>false</responseDataOnError>
            <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
            <assertionsResultsToSave>0</assertionsResultsToSave>
            <bytes>true</bytes>
          </value>
        </objProp>
        <stringProp name="filename"></stringProp>
      </ResultCollector>
      <hashTree/>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

=========================== JMX file ends================================== enter image description here ============================================================== ============== 在此处输入图像描述

enter image description here 在此处输入图片说明

enter image description here 在此处输入图片说明

Nope, JMeter will kick off 5 threads immediately then it will maintain 5 requests per minute, it means that each 12 seconds it will hit the server, it will last for 10 minutes. 不会,JMeter将立即启动5个线程,然后将每分钟维护5个请求,这意味着每12秒钟将命中服务器,它将持续10分钟。 So in total you will have approximately 50 + 5 samplers, the actual amount will vary depending on your response time. 因此,总共您将有大约50 + 5个采样器,实际数量将取决于您的响应时间。

See How to use JMeter's Constant Throughput Timer article for more details. 有关更多详细信息,请参见如何使用JMeter的“恒定吞吐量计时器”文章。


If you want JMeter to run 5 concurrent samplers each minute you need to go for different setup, to wit: 如果您希望JMeter每分钟运行5个并发采样器,则需要进行不同的设置,例如:

  • Your Sampler 您的采样器
  • Test Action Sampler - with Current Thread -> Pause -> 60000 测试动作采样器-具有Current Thread -> Pause -> 60000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM