DiceDB / dice

DiceDB is a redis-compliant, reactive, scalable, highly-available, unified cache optimized for modern hardware.
https://dicedb.io/
Other
6.79k stars 1.07k forks source link

Integrate Rate Limiter with command API and Return Rate Limit Headers #730

Closed lucifercr07 closed 1 month ago

lucifercr07 commented 1 month ago

Description

DiceDB Playground is an interactive platform that allows users to experiment with DiceDB commands in a live environment, similar to the Go Playground. Users will be able to submit and execute commands directly through a web interface. The initial implementation will focus on enabling users to search for and trigger commands.
For more details about DiceDB playground you can check here.

After implementing the global rate limiter, it needs to be integrated into the /command API to evaluate each incoming request against the rate limit. Additionally, the response should include headers to inform clients about their current rate limit status, similar to GitHub's rate-limiting headers.

The rate limiter should not apply to /search requests. However, for all other command requests, it should count each request and return detailed rate-limiting headers in the response.

Note: Implementation will be part of DiceDB playground backend repo.

Details

Tasks

  1. Integrate the rate limiter middleware with the /command API.
  2. Implement logic to handle blocked requests and return appropriate 429 Too Many Requests responses.
  3. Validate correctness of rate-limiting headers, normal API behaviour when under the rate limit, behaviour when the rate limit is reached and /search requests are not affected by the rate limiter.
ayushsatyam146 commented 1 month ago

I can take this up @lucifercr07

lucifercr07 commented 1 month ago

Dependent on #729

lucifercr07 commented 1 month ago

@ayushsatyam146 assigned, thanks for contributing. Please let me know if any other details required.

lucifercr07 commented 1 month ago

@ayushsatyam146 PRs have been merged now, please let me know if any other details required.

ayushsatyam146 commented 1 month ago

Thanks, I'm currently working on wrapping up one more issue. I'll work on this as soon as I'm done there.

lucifercr07 commented 1 month ago

@ayushsatyam146 were you be able to start on this?

ayushsatyam146 commented 1 month ago

Hi @lucifercr07 I just started working on this today. I'll raise a PR by Tomorrow

ayushsatyam146 commented 1 month ago

Hi @lucifercr07 added PR for this at https://github.com/DiceDB/playground-mono/pull/17

arpitbbhayani commented 1 month ago

Hello @ayushsatyam146,

There has been no activity on this issue for the past 5 days. It would be awesome if you keep posting updates to this issue so that we know you are actively working on it.

We are really eager to close this issue at the earliest, hence if we continue to see the inactivity, we will have to reassign the issue to someone else. We are doing this to ensure that the project maintains its momentum and others are not blocked on this work.

Just drop a comment with the current status of the work or share any issues you are facing. We can always chip in to help you out.

Thanks again.

lucifercr07 commented 1 month ago

Closing, merged as part of: https://github.com/DiceDB/playground-mono/pull/17