Great pkg for throttling but I have a concern..
|
lock (_processLocker) |
|
{ |
|
var entry = _counterStore.Get(counterId); |
|
if (entry.HasValue) |
|
{ |
|
// entry has not expired |
|
if (entry.Value.Timestamp + rule.PeriodTimespan.Value >= DateTime.UtcNow) |
|
{ |
|
// increment request count |
|
var totalRequests = entry.Value.TotalRequests + 1; |
|
|
|
// deep copy |
|
counter = new RateLimitCounter |
|
{ |
|
Timestamp = entry.Value.Timestamp, |
|
TotalRequests = totalRequests |
|
}; |
|
} |
|
} |
|
|
|
// stores: id (string) - timestamp (datetime) - total_requests (long) |
|
_counterStore.Set(counterId, counter, rule.PeriodTimespan.Value); |
According the code above, I see that you are locking every request with the static object and thus making all the requests to be processed synchronously, defeating the purpose of the web-server handling multiple requests at a time(asynchronously)
Am I missing something here ?
Great pkg for throttling but I have a concern..
AspNetCoreRateLimit/src/AspNetCoreRateLimit/Core/RateLimitCore.cs
Lines 60 to 81 in 5a027b3
According the code above, I see that you are locking every request with the static object and thus making all the requests to be processed synchronously, defeating the purpose of the web-server handling multiple requests at a time(asynchronously)
Am I missing something here ?