Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic URL cause high memory usage #1165

Open
Tracked by #1138
dpreindl opened this issue Jan 19, 2024 · 1 comment
Open
Tracked by #1138

Dynamic URL cause high memory usage #1165

dpreindl opened this issue Jan 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@dpreindl
Copy link

Brief summary

When running a k6 browser based test with multiple VUs, I noticed a steady increase of used memory. After trying to reduce the tests to a bare minimum, I came to the conclusion that this is caused by dynamic/non-unique URLs which are being called by the browser during the tests.
For me it seems that this is the browser version of what is being described in the k6 docs as url grouping here and here. - I would suspect the issue being related to the metric browser_http_req_duration.

xk6-browser version

1.2.1

OS

Debian Linux

Chrome version

Chromium 120.0.6099.199

Docker version and image (if applicable)

No response

Steps to reproduce the problem

Demo HTML page (Page with a title and a link):
demo-page.zip
Two versions are included:

  • index.html -> Clicking the link calls a dynamic URL (just adding the timestamp as query)
  • demo.html -> Clicking the link calls the same URL every time

Test script:

import { sleep } from "k6";
import { browser } from "k6/experimental/browser";

const DURATION = __ENV.DURATION || 2; // in minutes
const TARGET_VUS = __ENV.VUS || 1;
const URL = __ENV.URL || "http://127.0.0.1:8080/";

export const options = {
  scenarios: {
    DemoTest: {
      exec: "testDemoPage",
      executor: "ramping-vus",
      stages: [
        { duration: `${2 * 60}s`, target: TARGET_VUS }, // 2 minutes
        { duration: `${DURATION * 60}s`, target: TARGET_VUS },
      ],
      options: {
        browser: {
          type: "chromium",
        },
      },
    },
  },
};

export async function testDemoPage() {
  const page = browser.newPage();
  try {
    await page.goto(URL);
    for (let i = 0; i < 50; i++) {
      await page.locator("#load").click();
      sleep(0.2);
    }
  } finally {
    page.close();
  }
}

Expected behaviour

Moderate increase of memory

Actual behaviour

Running the Test with dynamic URLs being called results in a steady increase of memory (~ additionally 1 GB / hour):
memory_usage

The same test without the dynamic URL part:
memory_usage

Details (dynamic URLs):

  • pprof results (heap, allocation, go routines) & ps aux result after: 5min (base), ~40mn, ~60min
    dynamic-urls.zip

Details (same URL):

  • pprof results (heap, allocation, go routines) & ps aux result after: 5min (base), ~110min
    same-url.zip
@dpreindl dpreindl added the bug Something isn't working label Jan 19, 2024
@inancgumus
Copy link
Member

I'm adding this issue to the main #1138 issue. Thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants