首页 > 解决方案 > 批量使用 feeder,QPS 会很低,我的脚本有问题吗,tks

问题描述

csv文件大约47MB,如果我不使用batch,加载文件会花费很多时间,QPS可以达到8000+。 不要使用批处理

但如果我使用batch(10000)甚至更多batch(100000),QPS 将非常低,大约 800+。(文件有 100000 条记录) 使用批处理(100000)

像这样的脚本:

import io.gatling.core.Predef._
import io.gatling.core.feeder.BatchableFeederBuilder
import io.gatling.core.structure.ScenarioBuilder
import io.gatling.http.Predef._
import io.gatling.http.protocol.HttpProtocolBuilder

import scala.concurrent.duration._

class SuggestDot extends Simulation {

  val protoal: HttpProtocolBuilder = http.warmUp("https://www.baidu.com")
    .baseUrl("http://192.168.106.142:8080")
    .connectionHeader("keep-alive")
    .check(jsonPath("$.ret").ofType[Int] is 0)
    .check(jsonPath("$.data.data[0]") exists)

  val files: BatchableFeederBuilder[String]#F = csv("suggestDot.csv").batch(100000).circular

  val test: ScenarioBuilder = scenario("lalamap.myhll.cn").forever(
    feed(files).exec(
      http("suggest/doc")
        .get("${url}&isNewVersion=true")
    )
  )

  setUp(
    test.inject(atOnceUsers(100)).protocols(protoal)
  ).maxDuration(60 seconds)
}

标签: gatlingscala-gatling

解决方案


这将在即将发布的 Gatling 3.4.0 中修复,请参阅https://github.com/gatling/gatling/issues/3943https://github.com/gatling/gatling/issues/3944

顺便说一句,我可以从你的屏幕截图中看到你已经分叉了 Gatling。请考虑成为一名优秀的开源公民并为上游做出贡献。


推荐阅读