2021年1月22日星期五

Gatling prevent concurrent requests for same customer

I want to performance test a recommender system. It is important that the sequence of each product request for the same customer_id is respected as it influences the CPU load of the system under test.

How should I approach this? (This is what I have so far the exec does not work in the foreach)

  import io.gatling.core.Predef._  import io.gatling.http.Predef._      class MySimulation extends Simulation {    val baseUrl = "http://127.0.0.1:8080"  // http://127.0.0.1:8080/recommend/144/9200000033418652/    val contentType = "application/json"    var realtime_feeder = Array(      Map("product_ids" -> List("9200000118431183", "9200000118431213", "9200000089631081"), "customer_id" -> "1"),      Map("product_ids" -> List("9200000121305523"), "customer_id" -> "2"),      Map("product_ids" -> List("9200000118431349", "9200000089631025"), "customer_id" -> "3"),    )      val httpConfiguration = http.baseUrl(baseUrl)      .acceptHeader(contentType)      .contentTypeHeader(contentType)      .shareConnections      .warmUp(baseUrl)      val productRequest = http("Recommend ${customer_id} ${product_id}")      .get("/recommend/${customer_id}/${product_id}")      val scn = scenario("scenario")      .feed(realtime_feeder)      .foreach(session => {        val product_ids = session("product_ids").as[List[String]]        val customer_id = session("customer_id").as[String]        for (product_id <- product_ids){          exec(productRequest, customer_id, product_id)        }      },      )      setUp(      scn.inject(        atOnceUsers(2)      ).protocols(httpConfiguration))    }  
https://stackoverflow.com/questions/65850209/gatling-prevent-concurrent-requests-for-same-customer January 23, 2021 at 01:45AM

没有评论:

发表评论