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 requests per second graph to the HTML report. #381

Merged
merged 12 commits into from
Nov 19, 2021

Conversation

slashrsm
Copy link
Collaborator

@slashrsm slashrsm commented Nov 8, 2021

Closes #246.

TODO

  • Graph color scheme
  • Only display starting/stopping phase when --no-reset-metrics is used
  • Investigate spike on transition between starting and started phase
  • Confirm that metrics are correct (when throttling is enabled RPS numbers do not match exactly)
  • Automated tests
  • Add additional graphs.

Screenshots

With --no-reset-metrics

Screenshot 2021-11-18 at 20 53 10

Without --no-reset-metrics

Screenshot 2021-11-18 at 20 49 50

src/config.rs Outdated Show resolved Hide resolved
src/metrics.rs Outdated

/// Record request in requests per second metric.
pub(crate) fn record_requests_per_second(&mut self, bucket_size: usize) {
let time_bucket = (Utc::now().timestamp() - self.start_time) as usize / bucket_size;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the actual time of the request we are using the time when the request metric is reported.

It would be better to collect the time when the request happened, but I think that this data currently isn't reported by the worker.

src/report.rs Show resolved Hide resolved
Copy link
Member

@jeremyandrews jeremyandrews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fantastic seeing this feature come together!

As we only use the requests-per-second (and tasks-per-second and users-per-second etc) data when writing the html-report, perhaps we simply tie it to the existing --report-file option.

Specifying a bucket size doesn't seem to scale well, we need a mechanism that works regardless of if the load test runs for 5 minutes or 5 hours.

The code is clean and when it works it looks great -- very nice addition to the load test report!

src/metrics.rs Outdated Show resolved Hide resolved
src/metrics.rs Outdated Show resolved Hide resolved
src/config.rs Outdated Show resolved Hide resolved
src/config.rs Outdated Show resolved Hide resolved
src/config.rs Outdated Show resolved Hide resolved
src/report.rs Show resolved Hide resolved
src/config.rs Outdated Show resolved Hide resolved
src/report.rs Show resolved Hide resolved
src/metrics.rs Outdated Show resolved Hide resolved
@slashrsm slashrsm force-pushed the 246_html_report_graph branch 2 times, most recently from b87c207 to f54fc73 Compare November 10, 2021 20:01
@slashrsm
Copy link
Collaborator Author

I removed the options that were added in the initial version of this pull request and now we rely on --report-file to enable/disable this.

I also changed how the data is stored. Now we are storing the number of requests for each second and the (flawed) concept of "buckets" is now gone. Let me know what you think.

Also, what do you think about using something like this for the chart style: https://echarts.apache.org/examples/en/editor.html?c=area-simple. I imagine that it could be quite useful specially for long-running load tests (ability to zoom in, etc.).

Copy link
Member

@jeremyandrews jeremyandrews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much cleaner, thanks for reworking!

The graph should include ramp-up, running, and ramp-down (and ideally should visually indicate each somehow). I also like the idea of a different graph type that allows you to zoom in.

src/config.rs Outdated Show resolved Hide resolved
src/metrics.rs Outdated
@@ -2415,6 +2434,9 @@ impl GooseAttack {
if self.configuration.status_codes {
merge_request.set_status_code(request_metric.status_code);
}
if !self.configuration.report_file.is_empty() {
merge_request.record_requests_per_second(self.metrics.duration);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have self, so no need to pass self.metrics.duration

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The graph should include ramp-up time and ramp-down time -- in the following test I ran with the following parameters:

cargo run --release --example drupal_memcache -- --host http://apache/ -v -u5 -t10 --report-file report.html --throttle-requests 11

It's not including the ramp-up time, and it needs to. Also, I think we're missing the first second, as we should see 10 seconds of requests for ~11 rps:

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have self, so no need to pass self.metrics.duration

record_requests_per_second() is a function on a different struct so self represents something else there. And duration is not available there, so we need to send it.

@jeremyandrews
Copy link
Member

I also changed how the data is stored. Now we are storing the number of requests for each second and the (flawed) concept of "buckets" is now gone. Let me know what you think.

This is much simpler, I like it!

Note that the data is still getting cut off: I ran a load test for 1 hour (3600 seconds) but the data was cut off -- I manually added the missing bit of the report to see the data that was recorded. Likely this is a limitation of the current --report-file implementation, and a buffer or something will need to be increase to support larger file sizes.

image

Also, what do you think about using something like this for the chart style: https://echarts.apache.org/examples/en/editor.html?c=area-simple. I imagine that it could be quite useful specially for long-running load tests (ability to zoom in, etc.).

I like that idea very much, it would add richness to the charts being able to zoom in.

Perhaps the X axis should be actual timestamps though, instead of seconds since the test started? I wonder which is more useful? (The latter would be easier to match up against data in New Relic etc)

@slashrsm
Copy link
Collaborator Author

I am still trying to figure out the cutting off problem (I am able to reproduce it). I fell that there is something wrong with JSON serialization or maybe format! when the data series grows over certain point. Looking into it as we speak, but is quite time consuming, since I can only reproduce it if I run a load test for a while.

@slashrsm
Copy link
Collaborator Author

slashrsm commented Nov 11, 2021

I improved the appearance of the graph:

  1. Improved styling of the line
  2. Added zoom support
  3. Added tooltip on mouse hover
  4. Marked starting and stopping period (I can't make the latter to appear as it completes so quickly)
  5. Added "Save as image" function.

I noticed that there is always a spike of requests exactly at the point when the load test was started up and --no-reset-metrics. Is it possible that we are recording some requests twice in this case?

With --no-reset-metrics

Screenshot 2021-11-11 at 20-32-39 Goose Attack Report

Without --no-reset-metrics

Screenshot 2021-11-11 at 20-38-36 Goose Attack Report

@jeremyandrews
Copy link
Member

I think your graphs in the PR are labeled backwards -- the first one looks like --no-reset-metrics IS enabled, the second looks like --no-reset-metrics is NOT enabled.

@jeremyandrews
Copy link
Member

Any idea what this spike is at the start of the load test? It seems to show up in the graphs semi-regularly (in this case I'm using the following options: -v --report-file report.html -u10 -s10 -t10 --no-reset-metrics:

image

1 similar comment
@jeremyandrews
Copy link
Member

Any idea what this spike is at the start of the load test? It seems to show up in the graphs semi-regularly (in this case I'm using the following options: -v --report-file report.html -u10 -s10 -t10 --no-reset-metrics:

image

Copy link
Member

@jeremyandrews jeremyandrews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking very nice! I like the new charts much better.

  • When we are displaying starting/stopping, perhaps we could use "gray" instead of a red shade, as the latter draws more attention to it than it likely should
  • It would be ideal to create an automated test that confirms the data in the report is truly accurate
  • We either need to preserve a copy of requests made during Startup when running with "--no-reset-metrics" so we can show all data in the chart, or not show that section of time, as it's confusing/wrong to show it blank
  • I was able to run an hour long load test and got full data, the report file was only 117k

src/metrics.rs Outdated Show resolved Hide resolved
src/metrics.rs Show resolved Hide resolved
src/metrics.rs Outdated
&& Some(stopped) == self.metrics.stopped
{
let mut count = 0;
for (_path, path_metric) in self.metrics.requests.iter() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In src/metrics.rs see reset_metrics() which includes this logic:

                self.metrics.requests = HashMap::new();

Thus, in the default configuration all metrics from starting are not available to you by the time the html report is written. That explains the following chart:

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If --report-file is enabled and --no-reset-metrics is not enabled, we should store a copy of the metrics.requests "somewhere else" before we reset the metrics so we can generate a complete chart. Alternatively, in this configuration perhaps we should simply not display the "Starting" portion of the chart as it will always be blank.

@slashrsm
Copy link
Collaborator Author

I played with the color scheme and aspect ratio and I think that graph looks better now. Starting phase is only displayed when --no-reset-metrics is used and stopping phase is only displayed if it lasts for long enough to actually be visible on the graph.

Screenshots

With --no-reset-metrics

Screenshot 2021-11-18 at 20 53 10

Without --no-reset-metrics

Screenshot 2021-11-18 at 20 49 50

@jeremyandrews jeremyandrews marked this pull request as ready for review November 19, 2021 14:19
@jeremyandrews
Copy link
Member

This is a very nice enhancement, and only affects the HTML report generated when the load test ends. Committing as is: the rest of your TODO will make great followups -- thanks!

This pull request was closed.
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.

add charts to HTML report
3 participants