ThrottleX

A distributed rate-limiting solution built with Go and Redis, designed to control API traffic and ensure system stability. Supports multiple rate-limiting policies and is scalable with Docker for easy deployment.

APACHE-2.0 License

Stars
32

ThrottleX: Scalable Rate Limiting for Go APIs

Welcome to ThrottleX, a powerful and flexible rate-limiting library for Go! ThrottleX is designed to provide multiple rate limiting algorithms, easy integration, and scalable storage backends for your APIs.

For complete documentation, examples, and detailed setup instructions, please visit the ThrottleX Wiki.


Features

  • Multiple Algorithms:

    • Fixed Window
    • Sliding Window
    • Token Bucket
  • Pluggable Storage Backends:

    • In-Memory Store
    • Redis Store
  • Thread-Safe and Efficient:

    • Designed for high concurrency and low latency.
    • Includes mutex cleanup to prevent memory leaks.
  • Highly Configurable:

    • Customize limits, window sizes, and keys.
    • Support for dynamic configurations.
  • Future Expansion:

    • Upcoming support for additional rate limiting policies like Leaky Bucket, Concurrency Limit, and more.

Installation

To install Throttlex, use go get:

go get -u github.com/neelp03/throttlex

For detailed setup instructions, refer to the Installation and Setup Wiki Page.


Usage

Import the package into your Go project:

import (
    "github.com/neelp03/throttlex/ratelimiter"
    "github.com/neelp03/throttlex/store"
)

For full examples of integrating ThrottleX with REST, gRPC, and GraphQL APIs, please refer to the Examples Wiki Page.


Rate Limiting Algorithms

ThrottleX currently supports the following rate limiting algorithms:

  • Fixed Window Limiter
  • Sliding Window Limiter
  • Token Bucket Limiter

To learn more about these algorithms and how they work, visit the Rate Limiting Algorithms Wiki Page.


Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the Repository: Click on the "Fork" button at the top.

  2. Clone Your Fork:

    git clone https://github.com/neelp03/throttlex.git
    cd throttlex
    
  3. Create a Branch:

    git checkout -b feature/your-feature-name
    
  4. Make Changes: Implement your feature or fix.

  5. Run Tests:

    go test -race -v ./...
    
  6. Commit and Push:

    git add .
    git commit -m "Add your feature"
    git push origin feature/your-feature-name
    
  7. Create a Pull Request: Open a pull request against the main branch.


License

This project is licensed under the MIT License - see the LICENSE file for details.


Acknowledgments

  • Inspired by the need for flexible and efficient rate limiting in Go applications.
  • Thanks to the Go community for their invaluable contributions.

Contact

For questions or support, please open an issue on the GitHub repository.