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

Modify k6 load tests #5181

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Modify k6 load tests #5181

wants to merge 14 commits into from

Conversation

obulat
Copy link
Contributor

@obulat obulat commented Nov 25, 2024

Fixes

Fixes #5179 by @obulat

Description

The frontend k6 load test runs against the local Nuxt app on every CI run. Initially, when the test was added to run against the staging environment, it failed due to CPU limitations. To address this, we temporarily increased the staging CPU from 0.25 vCPU to 2 vCPU. However, our goal is to restore the staging environment to its previous resource levels while still reliably detecting potential memory leaks.

The k6 load tests run agains the locally-ran Nuxt app in the GitHub-hosted CI runners on every CI run, and then again after the PR is merged, against the Nuxt app deployed on staging. The GitHub-hosted CI runners use 4 CPU processor and 16 GB of RAM 1.

This PR adjusts the k6 test settings to maintain a constant request rate while preventing the tests from overwhelming the staging environment. It uses the constant-arrival-rate executor, which means that the rate of requests per seconds is constant, and does not depend on whether response was received or not.

After experimenting with different configurations, I think the following values will be a good start:

  • duration: 4-minute test is ensures that the load test completes within the CI pipeline timeframe, aligning with Playwright tests.
  • requests-per-second: I tried to lower this value 4 times, to match the required CPU usage in staging: from 7.28 rps to 1.72 rps. This was achieved by setting the rate for each scenario to 3 per minute. With six scenarios, this configuration results in an overall request rate of approximately 1.72 requests per second.

Here are some statistics from the k6 tests in staging, as well as the last 3 CI runs in this PR:

Metric Staging Environment GH CI Run 1 - Rate 30, Duration 5m GH CI Run 2 - Rate 10, Duration 5m GH CI Run 3 - Rate 3, Duration 4m
Requests Per Second (req/s) 7.28 req/s 16.05 req/s 5.39 req/s 1.72 req/s
Total Requests 4420 4832 1622 416
Total Test Duration ~10 minutes (607 seconds) ~5 minutes (301 seconds) ~5 minutes (301 seconds) ~4 minutes (240 seconds)
Average Request Time 3.47 seconds 153.4 milliseconds 140.08 milliseconds 197.71 milliseconds
Maximum Request Time 10.26 seconds 801.91 milliseconds 976.82 milliseconds 801.33 milliseconds
Dropped Iterations 235 0 0 0
Iterations 965 906 304 78
Iteration Rate 1.59 iterations/s 3.01 iterations/s 1.01 iterations/s 0.32 iterations/s

Deployment

For better testing how the k6 tests catch memory leaks and whether the new values are appropriate, I think the following process should be followed:

  1. Merge in the changes reverted in Fix frontend memory leak #4864, and see how the tests go in staging. We should see memory problems, manifested in either in a higher memory consumption in the AWS dashboard, or in the higher request timings/dropped iterations values.
  2. Merge in this PR to try to cap the CPU usage at 25% (since 25% of 2 vCPU should be equivalent to 100% of 0.25 vCPU). The values for the k6 tests should improve, but the memory leak should still be detectable.
  3. Revert the first change with the memory leak, confirm that the memory and CPU consumptions are within the lower limits of the staging values we want.
  4. Reduce the staging task resources.

Testing Instructions

Confirm that the deployment plan makes sense or suggest improvements.
Check the CI report for the load test and see that the requests per minutes are lower, and the test finishes within 4 minutes.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (ov just catalog/generate-docs for catalog
    PRs) or the media properties generator (ov just catalog/generate-docs media-props
    for the catalog or ov just api/generate-docs for the API) where applicable.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

Footnotes

  1. https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories

@openverse-bot openverse-bot added 🧱 stack: frontend Related to the Nuxt frontend 🟧 priority: high Stalls work on the project or its dependents 🧰 goal: internal improvement Improvement that benefits maintainers, not users 💻 aspect: code Concerns the software code in the repository labels Nov 25, 2024
Copy link

github-actions bot commented Nov 25, 2024

Latest k6 run output1

     ✓ status was 200

     checks.........................: 100.00% ✓ 416      ✗ 0   
     data_received..................: 96 MB   398 kB/s
     data_sent......................: 55 kB   226 B/s
     http_req_blocked...............: avg=51.24µs  min=2.47µs   med=4.79µs   max=1.05ms   p(90)=139.95µs p(95)=196.94µs
     http_req_connecting............: avg=36.46µs  min=0s       med=0s       max=1ms      p(90)=97.92µs  p(95)=126.8µs 
     http_req_duration..............: avg=196.78ms min=27.11ms  med=152.95ms max=766.21ms p(90)=377.4ms  p(95)=426.76ms
       { expected_response:true }...: avg=196.78ms min=27.11ms  med=152.95ms max=766.21ms p(90)=377.4ms  p(95)=426.76ms
   ✓ http_req_failed................: 0.00%   ✓ 0        ✗ 416 
     http_req_receiving.............: avg=162.21µs min=61.69µs  med=134.31µs max=679.98µs p(90)=270.1µs  p(95)=315.65µs
     http_req_sending...............: avg=26.42µs  min=7.52µs   med=22.68µs  max=207.14µs p(90)=38.22µs  p(95)=63.96µs 
     http_req_tls_handshaking.......: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=196.59ms min=26.99ms  med=152.84ms max=765.67ms p(90)=377.08ms p(95)=426.44ms
     http_reqs......................: 416     1.723528/s
     iteration_duration.............: avg=1.05s    min=648.23ms med=1.21s    max=1.98s    p(90)=1.35s    p(95)=1.37s   
     iterations.....................: 78      0.323161/s
     vus............................: 4       min=0      max=6 
     vus_max........................: 60      min=60     max=60

Footnotes

  1. This comment will automatically update with new output each time k6 runs for this PR

@obulat obulat self-assigned this Nov 25, 2024
@obulat obulat marked this pull request as ready for review November 25, 2024 13:32
@obulat obulat requested a review from a team as a code owner November 25, 2024 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟧 priority: high Stalls work on the project or its dependents 🧱 stack: frontend Related to the Nuxt frontend
Projects
Status: 👀 Needs Review
Development

Successfully merging this pull request may close these issues.

Modify the staging k6 load testing to allow for accurate tests with lower resources
2 participants