Skip to content

Implement Rate Limiting with Per-User/Per-Issuer Buckets and Metrics #12

Description

@grantfox-oss

Current rate limiting is global per the entire application. We need to implement per-user/per-issuer rate limiting to prevent single actors from monopolizing resources. This includes tracking per-issuer request quotas, implementing burst tolerance, and exposing rate limit metrics. Rate limit violations should be tracked and exposed via the metrics system for monitoring and alerting.

Affected Files:

  • src/rate_limit.rs (implement per-key rate limiting)
  • src/metrics.rs (add rate limit metrics tracking)
  • src/config.rs (add per-issuer rate limit configuration)

Acceptance Criteria:

  1. Replace global rate limiter with keyed rate limiter using issuer address as key
  2. Implement two-tier limits: per-issuer and global (with global taking precedence)
  3. Add configuration for per-issuer rate limits (e.g., 1000 requests/hour)
  4. Add metrics: rate_limit_hits_total, rate_limit_rejections_total (per issuer)
  5. Implement graceful rate limit response with Retry-After header
  6. Add endpoint to retrieve current rate limit status for user (remaining quota, reset time)
  7. Persist rate limit state to cache for distributed consistency
  8. Add tests for per-issuer rate limiting and burst scenarios
  9. Document rate limit tiers and quotas in API documentation

Impact:

  • Fair resource allocation
  • Prevents abuse and DoS scenarios
  • Better observability of system load

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions