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

Add library option to disable saving response bodies #325

Closed
bluekeyes opened this issue Aug 24, 2018 · 5 comments
Closed

Add library option to disable saving response bodies #325

bluekeyes opened this issue Aug 24, 2018 · 5 comments

Comments

@bluekeyes
Copy link

Proposal

Add an option for Attacker that does not save the response body into a buffer, but copies it directly to ioutil.Discard. I've implemented this in my fork: https://github.com/bluekeyes/vegeta/tree/bluekeyes/discard-body

Background

This is similar to #302, but slightly different. I'm using Vegeta as a library to test a download server, with file sizes ranging from 1kb to several GB. While the latest version of the CLI allows me to filter out the body from result files (or I could set the body to nil when using the library and processing results), reading large responses quickly uses up available memory during the test.

For the largest downloads in my test (0.25GB - 4GB), my test containers were running out of memory unpredictably based on the download rate (I tested with up to 8GB of available memory.) Since I don't use the response body for anything, discarding it keeps the memory usage low and allows the large tests to run with the same system resources as tests for smaller files.

Workarounds

Running tests on hosts with more memory or distributing the load across more machines can solve this problem, but is wasteful and may be hard to setup.

@tsenart
Copy link
Owner

tsenart commented Aug 24, 2018

Thanks for reporting this with such useful context. Out of curiosity, would test your servers with HEAD instead of GET solve the issue? Or do they not handle that method?

@bluekeyes
Copy link
Author

I didn't consider using HEAD requests, but in this case I don't think it would work. I'm mainly interested in how the server and the reverse proxy handle the data transfer as we adjust things like buffer settings or file system configuration. For that, it's important to send the file content to the client.

tsenart added a commit that referenced this issue Aug 24, 2018
This change set introduces a `-max-body` flag in the attack command
as well as the corresponding `vegeta.MaxBody` functional option to
use with `vegeta.NewAttacker`.

Fixes #325
tsenart added a commit that referenced this issue Aug 24, 2018
This change set introduces a `-max-body` flag in the attack command
as well as the corresponding `vegeta.MaxBody` functional option to
use with `vegeta.NewAttacker`.

Fixes #325
@tsenart
Copy link
Owner

tsenart commented Aug 24, 2018

@tsenart
Copy link
Owner

tsenart commented Aug 25, 2018

Feedback welcome :-)

@bluekeyes
Copy link
Author

Thanks for the quick turnaround on this. I haven't tested it out yet, but looking at the implementation I'm a bit worried that when setting the max body size to 0, the LimitReader won't actually read any data from the server, which could lead to weird behavior like the client closing the connection before reading the full body. When I get a chance to try it in my application, I'll update this with the results.

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

No branches or pull requests

2 participants