可以报​​告场景中第一个请求组的响应时间更长

时间:2019-12-11 03:04:55

标签: gradle servlets gatling scala-gatling gatling-plugin

我正在使用id“ com.github.lkishalmi.gatling”版本“ 3.2.9”来运行我的gatling性能测试

下面是我的模拟代码

  print("TIME "+System.currentTimeMillis())
  val httpConf = http.baseUrl("http://abc.io")
  val httpConf2 = http.baseUrl("  http://abc.io")
  val scenario_name = "only1_1in10"
  val scn = scenario(scenario_name)
    .exec(
      http("370kb"+"_"+scenario_name)
        .post("/pulse/swift/upload?startTime="+System.currentTimeMillis())
        //.body(StringBody("""{ "runId": """" + 0 + """", "imageName":"""" + imageName + """" }""")).asJson
        .bodyPart(RawFileBodyPart("file","src/gatling/simulations/370kb.png")).asMultipartForm
    ).exec(
    http("370kb_next"+"_"+scenario_name)
      .post("/pulse/swift/upload?startTime="+System.currentTimeMillis())
      //.body(StringBody("""{ "runId": """" + 0 + """", "imageName":"""" + imageName + """" }""")).asJson
      .bodyPart(RawFileBodyPart("file","src/gatling/simulations/370kb.png")).asMultipartForm
  ).exec(
    http("370kb_next_next"+"_"+scenario_name)
      .post("/pulse/swift/upload?startTime="+System.currentTimeMillis())
      //.body(StringBody("""{ "runId": """" + 0 + """", "imageName":"""" + imageName + """" }""")).asJson
      .bodyPart(RawFileBodyPart("file","src/gatling/simulations/370kb.png")).asMultipartForm
  )



  setUp(
    scn.inject(
      constantUsersPerSec(1) during (10)
    )
  ).protocols(httpConf).assertions(forAll.failedRequests.percent.is(0))

我只是将图像上传到服务器。服务器依次将这些图像推送到kafka队列并以200响应。

我在第一个HTTP组中拥有所有请求的问题总是很慢..而其他HTTP组则更快。我知道第一个请求将花费很长时间,因为服务器需要一些时间进行预热。但是我很困惑为什么所有10个请求都很慢。

以下是上述代码对同一图像的响应时间分布

enter image description here

enter image description here

enter image description here

有人可以解释为什么响应时间不断提高。第一组请求和后一组请求有什么区别?

我的服务器是一个简单的Spring Boot服务器,它接受多部分请求并将其推送到Kafka队列。


在不同情况下分隔后的

代码

import io.gatling.http.Predef._
import io.gatling.core.Predef._
class OneSimulation extends Simulation {
  print("TIME "+System.currentTimeMillis())
  val httpConf = http.baseUrl("http://abc.io")
  val httpConf2 = http.baseUrl("  http://abc.io")
  val scenario_name = "only1_1in10"
  val scn = scenario(scenario_name)
    .exec(
      http("370kb"+"_"+scenario_name)
        .post("/pulse/swift/upload?startTime="+System.currentTimeMillis())
        //.body(StringBody("""{ "runId": """" + 0 + """", "imageName":"""" + imageName + """" }""")).asJson
        .bodyPart(RawFileBodyPart("file","src/gatling/simulations/370kb.png")).asMultipartForm
    )

  val scenario_name2 = "only1_1in10_2"
  val scn2 = scenario(scenario_name2)
    .exec(
      http("370kb"+"_"+scenario_name2)
        .post("/pulse/swift/upload?startTime="+System.currentTimeMillis())
        //.body(StringBody("""{ "runId": """" + 0 + """", "imageName":"""" + imageName + """" }""")).asJson
        .bodyPart(RawFileBodyPart("file","src/gatling/simulations/370kb.png")).asMultipartForm
    )

  val scenario_name3 = "only1_1in10_3"
  val scn3 = scenario(scenario_name3)
    .exec(
      http("370kb"+"_"+scenario_name3)
        .post("/pulse/swift/upload?startTime="+System.currentTimeMillis())
        //.body(StringBody("""{ "runId": """" + 0 + """", "imageName":"""" + imageName + """" }""")).asJson
        .bodyPart(RawFileBodyPart("file","src/gatling/simulations/370kb.png")).asMultipartForm
    )



  setUp(
    scn.inject(
       //atOnceUsers(20)
      //rampUsers(10)during(10)
      constantUsersPerSec(1) during (10)
      //atOnceUsers(20),
    ),
    scn2.inject(
      //atOnceUsers(20)
      //rampUsers(10)during(10)
      constantUsersPerSec(1) during (10)
      //atOnceUsers(20),
    ),
    scn3.inject(
      //atOnceUsers(20)
      //rampUsers(10)during(10)
      constantUsersPerSec(1) during (10)
      //atOnceUsers(20),
    )

    //rampUsersPerSec(10) to(20) during(10) randomized)
  ).protocols(httpConf).assertions(forAll.failedRequests.percent.is(0))




}

enter image description here

enter image description here

enter image description here

在不同的场景中分开可以给出相似的响应时间。但是,将所有请求置于同一场景中会使我对第一个组的响应时间变慢,但对后一组的响应时间变长。有人可以帮我解释一下这种行为

0 个答案:

没有答案
相关问题