TsgcWSRateLimiterProperties › PerIP

PerIP Property

Rate-limit rule scoped to the source IP address.

Syntax

property PerIP: TsgcRateLimitRule read FPerIP write SetPerIP;

Default Value

Remarks

Exposes Enabled, MaxRequests, WindowSec and Strategy (rlsTokenBucket, rlsSliding or rlsFixed). When a request key does not match PerEndpoint, PerAPIKey or PerUser, PerIP becomes the active rule and overrides the global Token/Sliding/Fixed defaults. Each IP gets its own independent counter, so one noisy client cannot consume the global budget and starve everyone else. For Token Bucket, MaxRequests is the bucket capacity and the refill rate is derived as MaxRequests / WindowSec tokens per second.

Example

// Every client IP gets its own 100 req/min bucket
sgcWSRateLimiter1.PerIP.Enabled := True;
sgcWSRateLimiter1.PerIP.Strategy := rlsTokenBucket;
sgcWSRateLimiter1.PerIP.MaxRequests := 100;
sgcWSRateLimiter1.PerIP.WindowSec := 60;

Back to Properties