{"id":22138192,"url":"https://github.com/seatedro/drl","last_synced_at":"2025-03-24T10:26:04.416Z","repository":{"id":264731360,"uuid":"894047067","full_name":"seatedro/drl","owner":"seatedro","description":"Distributed Rate Limiter","archived":false,"fork":false,"pushed_at":"2025-02-23T03:28:12.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-23T04:19:22.956Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seatedro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-25T16:52:17.000Z","updated_at":"2025-02-23T03:28:15.000Z","dependencies_parsed_at":"2024-11-26T03:17:59.384Z","dependency_job_id":null,"html_url":"https://github.com/seatedro/drl","commit_stats":null,"previous_names":["seatedro/drl"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seatedro%2Fdrl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seatedro%2Fdrl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seatedro%2Fdrl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seatedro%2Fdrl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seatedro","download_url":"https://codeload.github.com/seatedro/drl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245251040,"owners_count":20584819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-01T20:08:59.450Z","updated_at":"2025-03-24T10:26:04.397Z","avatar_url":"https://github.com/seatedro.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Distributed Rate Limiter (DRL)\n\nA high-performance, distributed rate limiter built in Go, supporting both HTTP and gRPC protocols. Uses Redis for distributed state management and implements the Token Bucket algorithm for precise rate limiting.\n\n## Features\n\n- **Distributed Rate Limiting**: Consistent rate limiting across multiple service instances\n- **Dual Protocol Support**: Both HTTP and gRPC interfaces\n- **Token Bucket Algorithm**: Efficient and flexible rate limiting with burst support\n- **Redis Backend**: Scalable and reliable state management\n- **Configurable Limits**: Adjust rates, windows, and burst sizes via environment variables\n- **Docker Ready**: Easy deployment with Docker and Docker Compose\n\n## Architecture\n\n```\n[Client Requests] \n       ↓\n[Load Balancer]\n       ↓\n[Rate Limiter Service Instances] ←→ [Redis Cluster]\n```\n\n## Getting Started\n\n### Prerequisites\n\n- Go 1.22 or later\n- Docker and Docker Compose\n- Redis (for development)\n\n### Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/seatedro/drl.git\ncd drl\n```\n\n2. Install dependencies:\n```bash\ngo mod download\n```\n\n3. Generate protocol buffers:\n```bash\nmake generate\n```\n\n### Running with Docker Compose\n\n```bash\ndocker-compose up --build\n```\n\nThis will start:\n- Rate limiter service (HTTP :8080, gRPC :9090)\n- Redis instance\n- Load testing service\n\n## Usage\n\n### HTTP API\n\n```bash\n# Check if request is allowed\ncurl -X POST \"http://localhost:8080/v1/allow/my-key?namespace=myapp\"\n\n# Reset rate limit for a key\ncurl -X POST \"http://localhost:8080/v1/reset/my-key?namespace=myapp\"\n```\n\n### gRPC API\n\n```bash\n# Using grpcurl\ngrpcurl -d '{\"key\": \"my-key\", \"namespace\": \"myapp\"}' \\\n    -plaintext localhost:9090 drl.v1.RateLimiter/Allow\n```\n\n### Response Headers (HTTP)\n\n```\nX-RateLimit-Remaining: \u003cremaining requests\u003e\nX-RateLimit-Reset: \u003creset timestamp\u003e\nRetry-After: \u003cseconds until next available request\u003e\n```\n\n## Configuration\n\nEnvironment variables:\n\n| Variable | Description | Default |\n|----------|-------------|---------|\n| RATE_LIMIT | Requests allowed per window | 100 |\n| RATE_WINDOW | Time window in seconds | 60 |\n| BURST_SIZE | Maximum burst size | 150 |\n| DEBUG | Enable debug logging | false |\n\n## Load Testing\n\nThe project includes comprehensive load testing for both HTTP and gRPC endpoints:\n\n```bash\n# Run load tests\ndocker-compose up loadtest\n```\n\nTest scenarios include:\n- Burst capacity testing\n- Sustained load testing\n- High concurrency testing\n- Rate limit recovery testing\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseatedro%2Fdrl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseatedro%2Fdrl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseatedro%2Fdrl/lists"}