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

Document the importance of sleep #900

Open
MattDodsonEnglish opened this issue Nov 16, 2022 · 5 comments
Open

Document the importance of sleep #900

MattDodsonEnglish opened this issue Nov 16, 2022 · 5 comments
Labels
Area: OSS Content Improvements or additions to community/oss documentation Tech Writers Issues that a writer could help with

Comments

@MattDodsonEnglish
Copy link
Contributor

For developers who don't come from a testing background, the sleep() function can be confusing. Why waste CPU cycles doing nothing?

We have sleep recommendations in the browser recorder, a mention in the "high CPU" insight, and some mentions in k6-learn, but it'd be nice to have a more findable description, since sleep is in so many of our example scripts, and little "best practices" like this are some of the most requested docs.

@MattDodsonEnglish MattDodsonEnglish added Area: OSS Content Improvements or additions to community/oss documentation Tech Writers Issues that a writer could help with labels Nov 16, 2022
@imiric
Copy link
Contributor

imiric commented Nov 16, 2022

We could just link to https://www.sleepfoundation.org/how-sleep-works/why-do-we-need-sleep :trollface:

But to add something constructive: sleep() is very important to simulate actual user behavior. Users don't just hammer a web site like a bot would, and a lot of time is spent rendering and interacting with the frontend. Running a browser test represents that scenario better, and part of the use case for k6 is to stress the SUT and not behave exactly like a user would. But even in that case, sleep() is useful to pace the generated load, and not overload the load generator machine. Given that k6 is not strictly a load testing tool, but encompasses many different areas of observability, waiting for a specific amount of time is useful in other testing scenarios as well. So I agree that we should have a document to mention some of these examples.

@sniku
Copy link
Collaborator

sniku commented Jan 27, 2023

I think the most important is to document that sleep() is a bad idea for arrival rate executors. At least, sleep should not be added at the end of the iteration, as we recommend for other executors.

@mstoykov
Copy link
Contributor

On similar note ☝️ we likely should get something like delay for asynchronous code as sleep is blocking and synchronous.

@MattDodsonEnglish
Copy link
Contributor Author

I think the most important is to document that sleep() is a bad idea for arrival rate executors. At least, sleep should not be added at the end of the iteration, as we recommend for other executors.

I just made a small note to account for this, if someone wants to review.

https://github.com/grafana/k6-docs/pull/1008/files

MattDodsonEnglish added a commit that referenced this issue Jan 31, 2023
#900 

Co-authored-by: Mihail Stoykov <312246+mstoykov@users.noreply.github.com>
@ppcano
Copy link
Collaborator

ppcano commented Apr 3, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: OSS Content Improvements or additions to community/oss documentation Tech Writers Issues that a writer could help with
Projects
None yet
Development

No branches or pull requests

5 participants