Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rate Limiting in Flask API #47

Open
pratikj697 opened this issue Oct 5, 2024 · 5 comments
Open

Rate Limiting in Flask API #47

pratikj697 opened this issue Oct 5, 2024 · 5 comments

Comments

@pratikj697
Copy link

In any web application, especially APIs, it’s essential to manage the rate at which clients can make requests to prevent abuse, ensure fair usage, and protect server resources. Without a rate limiting mechanism, malicious users could potentially overwhelm the server by making a large number of requests in a short period, leading to denial of service (DoS) attacks or degradation of service for legitimate users.

Please assign this problem to me under HactoberFest 2024 and i hope this topic is useful in your current project.

@geekyharsh05
Copy link
Contributor

@pratikj697 But it is an express api, Why you have written flask?

@pratikj697
Copy link
Author

@pratikj697 But it is an express api, Why you have written flask?

Thank you for your feedback! I appreciate the opportunity to clarify. The implementation I provided is based on a Flask API written in Python. It focuses on rate limiting using Redis, which is an essential feature for managing client requests effectively.

I mistakenly mentioned it in the context of the repository without realizing it was intended for an Express API, which uses Node.js.

@geekyharsh05
Copy link
Contributor

@pratikj697 But you can use simple rate-limit libraries also. https://www.npmjs.com/package/express-rate-limit

@pratikj697
Copy link
Author

@pratikj697 But you can use simple rate-limit libraries also. https://www.npmjs.com/package/express-rate-limit

However, I believe there are several reasons why my implementation should be considered for inclusion in this repository:

  1. Framework Compatibility: My implementation is specifically designed for a Flask API, which caters to Python developers. While express-rate-limit is an excellent library for Node.js, it wouldn’t be applicable for projects using Flask or Python frameworks.
  2. Customizability: The provided implementation allows for easy customization of the rate limiting logic, such as changing the maximum requests and time window. This flexibility enables developers to adjust the limits based on their specific needs without being bound by predefined configurations.
  3. Educational Value: Including this implementation can serve as an educational resource for other developers who may be new to Flask or rate limiting concepts. It demonstrates how to integrate Redis for tracking request counts and offers insights into how rate limiting works at a fundamental level.
  4. No External Dependencies: The implementation directly integrates Redis for rate limiting without relying on additional libraries. This can simplify dependency management for developers who prefer minimal setups.
  5. Functionality: The solution addresses the core needs of rate limiting, including error handling for excessive requests and IP-based tracking, making it a comprehensive example of how to implement this feature.
  6. Potential for Further Development: If this implementation is included, it opens up opportunities for future enhancements, such as adding more complex rate limiting strategies, improving error responses, or integrating with additional storage backends.

In Conclusion:
I believe this implementation aligns with the goals of the repository and can provide value to users looking for a Python-based solution for rate limiting in Flask. I’m open to further discussion and am happy to make adjustments based on your insights.

@geekyharsh05
Copy link
Contributor

geekyharsh05 commented Oct 6, 2024

@pratikj697 What is the TLDR of this?
You want to implement your flask method in node js?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants