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

Find and fix deprecated APIs in k6 #41

Merged
merged 2 commits into from
May 4, 2022
Merged

Find and fix deprecated APIs in k6 #41

merged 2 commits into from
May 4, 2022

Conversation

mostafa
Copy link
Owner

@mostafa mostafa commented May 2, 2022

This PR fixes deprecated APIs errors while running k6 (#38) and replaces them with the new APIs from k6 modules. The only issue with the changes is that SASL PLAIN/SCRAM doesn't seem to work. I'll fix this issue, and then I'll merge this PR.

I retested with the old API, and I noticed no difference or improvements in performance overall. It could be that the evolution of the kafka-go library and updating the k6 caused this massive speedup (expand and see below) compared to the original test in the README.

xk6-kafka is faster now? 🤔

The new changes made the extension more than 3x faster on fast-data-dev containers:

          /\      |‾‾| /‾‾/   /‾‾/
     /\  /  \     |  |/  /   /  /
    /  \/    \    |     (   /   ‾‾\
   /          \   |  |\  \ |  (‾)  |
  / __________ \  |__| \__\ \_____/ .io

  execution: local
     script: scripts/test_json.js
     output: -

  scenarios: (100.00%) 1 scenario, 50 max VUs, 1m30s max duration (incl. graceful stop):
           * default: 50 looping VUs for 1m0s (gracefulStop: 30s)


running (1m00.2s), 00/50 VUs, 9653 complete and 0 interrupted iterations
default ✓ [======================================] 50 VUs  1m0s

     ✓ is sent
     ✓ 10 messages returned

     █ teardown

     checks.........................: 100.00% ✓ 974953       ✗ 0
     data_received..................: 0 B     0 B/s
     data_sent......................: 0 B     0 B/s
     iteration_duration.............: avg=311.24ms min=33.87µs med=301.12ms max=767.25ms p(90)=354.48ms p(95)=385.52ms
     iterations.....................: 9653    160.396792/s
     kafka.reader.dial.count........: 50      0.830813/s
     kafka.reader.error.count.......: 0       0/s
     kafka.reader.fetches.count.....: 50      0.830813/s
     kafka.reader.message.bytes.....: 19 MB   315 kB/s
     kafka.reader.message.count.....: 96580   1604.798737/s
     kafka.reader.rebalance.count...: 0       0/s
     kafka.reader.timeouts.count....: 0       0/s
     kafka.writer.dial.count........: 150     2.49244/s
     kafka.writer.error.count.......: 0       0/s
     kafka.writer.message.bytes.....: 422 MB  7.0 MB/s
     kafka.writer.message.count.....: 1930600 32079.358475/s
     kafka.writer.rebalance.count...: 0       0/s
     kafka.writer.write.count.......: 1930600 32079.358475/s
     vus............................: 50      min=50         max=50
     vus_max........................: 50      min=50         max=50

and 4x faster on a bare Zookeeperless instance of Apache Kafka (v3.1.0 on Scala v2.13), compared to the previous results:

          /\      |‾‾| /‾‾/   /‾‾/
     /\  /  \     |  |/  /   /  /
    /  \/    \    |     (   /   ‾‾\
   /          \   |  |\  \ |  (‾)  |
  / __________ \  |__| \__\ \_____/ .io

  execution: local
     script: scripts/test_json.js
     output: -

  scenarios: (100.00%) 1 scenario, 50 max VUs, 1m30s max duration (incl. graceful stop):
           * default: 50 looping VUs for 1m0s (gracefulStop: 30s)


running (1m00.1s), 00/50 VUs, 13598 complete and 0 interrupted iterations
default ✓ [======================================] 50 VUs  1m0s

     ✓ is sent
     ✓ 10 messages returned

     █ teardown

     checks.........................: 100.00% ✓ 1373398      ✗ 0
     data_received..................: 0 B     0 B/s
     data_sent......................: 0 B     0 B/s
     iteration_duration.............: avg=220.82ms min=28.5µs med=215.94ms max=987.93ms p(90)=248.22ms p(95)=258.71ms
     iterations.....................: 13598   226.195625/s
     kafka.reader.dial.count........: 50      0.831724/s
     kafka.reader.error.count.......: 0       0/s
     kafka.reader.fetches.count.....: 50      0.831724/s
     kafka.reader.message.bytes.....: 27 MB   444 kB/s
     kafka.reader.message.count.....: 136030  2262.787977/s
     kafka.reader.rebalance.count...: 0       0/s
     kafka.reader.timeouts.count....: 0       0/s
     kafka.writer.dial.count........: 132     2.195751/s
     kafka.writer.error.count.......: 0       0/s
     kafka.writer.message.bytes.....: 595 MB  9.9 MB/s
     kafka.writer.message.count.....: 2719600 45239.125059/s
     kafka.writer.rebalance.count...: 0       0/s
     kafka.writer.write.count.......: 2719600 45239.125059/s
     vus............................: 50      min=50         max=50
     vus_max........................: 50      min=50         max=50

Update:
I couldn't figure out how to test SASL (no SSL), and I need someone to test it against a working instance of Kafka with SASL PLAIN/SCRAM enabled. I'll merge this, but won't release it until I fully test it. This means that you can test the feature by compiling with the latest commits on the main branch, but it won't be available as binary and a Docker image yet.

Apparently the new changes made the extension more than 4x faster with the same test on a zookeeperless (Kraft) Kafka v3.1.0 on Scala v2.13.
@mostafa mostafa merged commit 92ef346 into main May 4, 2022
@mostafa mostafa deleted the fix-deprecated-apis-38 branch May 4, 2022 17:39
mostafa added a commit that referenced this pull request May 31, 2022
* Find and fix deprecated APIs in k6
* Fix linting issues reported by golangci-lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant