java.lang.OutOfMemoryError: Java heap space error

we are testing service running in localhost:8080, and testing simple rest end points.

not sure why it returns memory error, can you please advise?

ProcessCustomer


 val feeder: Iterator[Map[String, Any]] = Iterator.continually(
    Map("id" -> Random.alphanumeric.take(9).mkString, "name" -> Random.alphanumeric.take(10).mkString)
  )

  val id = "id"

val processCustomers: ScenarioBuilder = scenario("Post Put Delete Customers")
    .repeat(1) {
      feed(feeder)
        .exec(http(requestName = "Post Customers")
          .post(Constants.postURL)
          .body(ElFileBody("body/customersPost.json")).asJson
          .check(status.in(200)))
        .exec(http(requestName = "Put Customers")
          .put(s"/customers/#{$id}")
          .body(ElFileBody("body/customersPut.json")).asJson
          .check(status.in(200)))
        .exec(http(requestName = "Get Customer By ID after Post Request")
          .get(s"/customers/#{$id}")
          .check(status.in(200)))
    }

Simulation:

 setUp(
    getCustomers.inject(nothingFor(1 seconds), atOnceUsers(15), rampUsers(485).during(600 seconds)),
    processCustomers.inject(nothingFor(1 seconds), rampUsersPerSec(10).to(300).during(30.minutes))
      .andThen(
        getAllCustomers.inject(nothingFor(1 seconds), rampUsersPerSec(10).to(300).during(30.minutes))
          .andThen(
            deleteCustomers.inject(nothingFor(1 seconds), rampUsersPerSec(10).to(100).during(10.minutes))
          )
      )
  ).protocols(httpConf)

Hi @Banu,

So you are load testing an application that runs on the same machine as the load test?

It means that the whole stack is on your machine (I guess) AND Gatling is running there too. They compete for your machine resources, for sure.

Cheers!

yes,

yes, running backend service and load test that service on the same machine.

do you mean that machine resources are not enough to ramp up users, due to not having sufficient memory? it is a simple resi api application that we are trying to test using gatling.

do i have to reduce ramp up rate in that case, to ramp up less no of users? Can you please advise?

@Banu,

My advice: do not run on the same machine were application and load test will compete for resources.
You won’t be able to find if your application stack is leaking memory, or use too much CPU, or if the issue is your simulation.

Separation of concerns is the keyword, here.

Cheers!

This simulation file works fine, when we ran for 30 mins, but when we ran for 30 mins, it failed.

The changes are- we have DeleteCustomer api added to processCustomers: ScenarioBuilder, and increased duration from 30 mins to 20 mins in the setup, and ramp up rate remains the same,

any reason why the below change is working fine, but not the above one?

val processCustomers: ScenarioBuilder = scenario("Post Put Delete Customers")
    .repeat(1) {
      feed(feeder)
        .exec(http(requestName = "Post Customers")
          .post(Constants.postURL)
          .body(ElFileBody("body/customersPost.json")).asJson
          .check(status.in(200)))
        .exec(http(requestName = "Put Customers")
          .put(s"/customers/#{$id}")
          .body(ElFileBody("body/customersPut.json")).asJson
          .check(status.in(200)))
        .exec(http(requestName = "Get Customer By ID after Post Request")
          .get(s"/customers/#{$id}")
          .check(status.in(200)))
        **.exec(http(requestName = "Delete Customers")**
**          .delete(s"/customers/#{$id}")**
**          .check(status.in(200)))**
    }

  setUp(
    getCustomers.inject(nothingFor(1 seconds), atOnceUsers(15), rampUsers(485).during(600 seconds)),
    processCustomers.inject(nothingFor(1 seconds), rampUsersPerSec(10).to(300).**during(20.minutes))**
      .andThen(
        getAllCustomers.inject(nothingFor(1 seconds), rampUsersPerSec(10).to(100).during(**10.minutes))**)
  ).protocols(httpConf)

we also notice Connection time out when we ran getAllCustomer with ramp up rate rampUsersPerSec(10).to(300).during(20.minutes)), is it also related to memory resources?

setUp(
  getCustomers.inject(nothingFor(1 seconds), atOnceUsers(15), rampUsers(485).during(600 seconds)),
  processCustomers.inject(nothingFor(1 seconds), rampUsersPerSec(10).to(300).during(20.minutes))
    .andThen(
      **getAllCustomers.inject(nothingFor(1 seconds), rampUsersPerSec(10).to(300).during(20.minutes))**
        .andThen(
          deleteCustomers.inject(nothingFor(1 seconds), rampUsersPerSec(10).to(100).during(10.minutes))
        )
    )
).protocols(httpConf)

Hi @Banu , as stated before that
your local machine doesn't have enough resources to run both services and Gatling in the same time
Please follow this sharing to understand how JSON works:

your simple REST API application may use up resources without noticing.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.