liveBook · Manning

Rate limit

As explained in Pro ASP.NET Core 7, Tenth Edition

Rate limiting is the technique of restricting the number or frequency of requests handled during a specified interval or according to available capacity.

Rate limiting restricts how many requests an ASP.NET Core application handles during a period or according to available capacity. It helps prevent heavy traffic from overwhelming the application, but rejected requests can surprise clients when capacity is exhausted. section 16.5

Configure rate limiting through the service collection and apply a named policy to endpoints or controllers.

  • Set PermitLimit, QueueLimit, and the limiter-specific duration or capacity options; apply the named policy with RequireRateLimiting. section 16.5

One request every 15 seconds

Register a fixedWindow policy with PermitLimit = 1, QueueLimit = 0, and a 15-second Window, then enable rate-limiting middleware. Apply the policy to a controller with [EnableRateLimiting("fixedWindow")]. Add [DisableRateLimiting] to an action that must remain unrestricted. Reloading the limited collection endpoint produces a 503 after the first request, while the exempt detail endpoint remains available. section 19.5.7

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Explains four limiter types, shared options, middleware registration, named policies, and endpoint or controller application.
Examples
Demonstrates a one-request-per-15-seconds fixed window, zero queue, controller attributes, endpoint exemption, and a resulting 503.
What it assumes
Assumes familiarity with ASP.NET Core request pipelines, endpoints, controllers, and Program.cs service configuration.
What you can do after
Operate/configure named ASP.NET Core rate-limiting policies and verify limited and exempt routes through browser requests.
How it connects
Connects rate limiting with middleware, endpoints, controllers, attributes, options patterns, and HTTP status responses.

Also explained in

Compare how 14 books explain rate limit →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.