Skip to main content
InterviewHubPRO
Section Overview
Q40

Question 40 of 50

Part 3: Distributed Systems, Kestrel Internals & Scalability (25 - 35)

80%
ASP.NET Core & Web API (50 Qs)•Part 3: Distributed Systems, Kestrel Internals & Scalability (25 - 35)

Native Rate Limiting Middleware in .NET 7/8+.

senior LevelMost AskedCode ExampleSystem Design

In Simple Words: Built-in rate limiting (Microsoft.AspNetCore.RateLimiting) protects endpoints from denial-of-service without external proxies:

  1. Fixed Window: Allows $N$ requests per calendar interval.
  2. Sliding Window: Smooths out traffic spikes across window segments.
  3. Token Bucket: Accumulates tokens up to a capacity and replenishes continuously; permits bursts while enforcing long-term limits.
  4. Concurrency Limiter: Limits the number of concurrent in-flight requests executing simultaneously.
csharp
app.UseRateLimiter(new RateLimiterOptions()
    .AddTokenBucketLimiter("api-policy", options => {
        options.TokenLimit = 100;
        options.ReplenishmentPeriod = TimeSpan.FromSeconds(10);
        options.TokensPerPeriod = 20;
    }));