Skip to content

Overhead Benchmark for Request Throttling #10907

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

Merged
merged 9 commits into from
Jun 13, 2019
Merged

Conversation

DylanDmitri
Copy link
Contributor

There's a benchmark project!

The single included benchmark captures the overhead of requests passing directly through the middleware (which happens the server has extra room). The baseline represents calling the rest of the pipeline directly without passing through the middleware. Comparing these two numbers, we can get an estimate for the overhead.

Method Mean Error StdDev Op/s Gen 0 Allocated
Baseline 1.697 us 0.0337 us 0.0904 us 589,400.1 3.9063 296 B
WithEmptyQueueOverhead 2.080 us 0.0556 us 0.1585 us 480,863.7 7.8125 440 B


private async Task NextDelay(HttpContext context)
{
for (int i = 0; i < 1000; i++) { }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need a better way to represent work. spoopy.

@DylanDmitri DylanDmitri changed the title Dylan/overhead benchmark Overhead Benchmark for Request Throttling Jun 5, 2019
@DylanDmitri
Copy link
Contributor Author

Current runs:

Method YieldsThreadInternally Mean Error StdDev Op/s Gen 0 Allocated
Baseline False 4.599 ns 0.0968 ns 0.2145 ns 217,423,611.1 - 0 B
WithEmptyQueueOverhead False 158.331 ns 3.1055 ns 5.1025 ns 6,315,868.6 - 0 B
Baseline True 1,154.286 ns 22.1071 ns 24.5720 ns 866,336.0 31.2500 296 B
WithEmptyQueueOverhead True 1,596.948 ns 32.8273 ns 92.5899 ns 626,194.5 125.0000 0 B

@DylanDmitri DylanDmitri force-pushed the dylan/overheadBenchmark branch from 3922dfc to 8a55fc9 Compare June 7, 2019 20:03
@DylanDmitri DylanDmitri force-pushed the dylan/overheadBenchmark branch from 8a55fc9 to a9337ff Compare June 7, 2019 23:53
@DylanDmitri
Copy link
Contributor Author

@halter73 am I good to merge here?

Also I've snuck a IRequestQueue interface into here, to support different queue implementations in the future. It shouldn't technically be in this PR sorry.


namespace Microsoft.AspNetCore.RequestThrottling.Internal
{
internal class TailDrop : RequestQueue
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't just change the default to TailDrop. Keep all the existing tests fro the base RequestQueue and add special tests for TailDrop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hopefully will have multiple queue implementations soon, will run the existing tests on all of them.

RequestQueueLimit = requestQueueLimit
};

options.ServerAlwaysBlocks = maxConcurrentRequests == 0;
Copy link
Member

Choose a reason for hiding this comment

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

This check should be in options or the middleware. Right now this only work if you use TestUtils.

Copy link
Member

Choose a reason for hiding this comment

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

I think I understand now. What you have is fine, just use a different method for the ServerAlwaysBlocks case.

@@ -15,6 +15,8 @@ namespace RequestThrottlingSample
{
public class Startup
{
private int totalLoads = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
private int totalLoads = 0;
private int _totalLoads = 0;

_requestThrottlingOptions.MaxConcurrentRequests.Value,
_requestThrottlingOptions.RequestQueueLimit);

if (_requestThrottlingOptions.ServerAlwaysBlocks)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: comment here too that this is for testing only

@aspnet-hello
Copy link

This comment was made automatically. If there is a problem contact [email protected].

I've triaged the above build. I've created/commented on the following issue(s)
https://github.com/aspnet/AspNetCore-Internal/issues/2667

@DylanDmitri DylanDmitri merged commit 844530d into master Jun 13, 2019
@ghost ghost deleted the dylan/overheadBenchmark branch June 13, 2019 00:22
@amcasey amcasey added the area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares label Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants