{"id":16863569,"url":"https://github.com/vbrazo/rate_limiter","last_synced_at":"2026-04-16T11:31:37.194Z","repository":{"id":46645814,"uuid":"353016737","full_name":"vbrazo/rate_limiter","owner":"vbrazo","description":"Rate Limiter engine for Rails APIs","archived":false,"fork":false,"pushed_at":"2021-10-01T22:01:30.000Z","size":75,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T20:29:57.778Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vbrazo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-30T13:46:18.000Z","updated_at":"2023-03-30T01:23:52.000Z","dependencies_parsed_at":"2022-08-28T19:23:51.134Z","dependency_job_id":null,"html_url":"https://github.com/vbrazo/rate_limiter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbrazo%2Frate_limiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbrazo%2Frate_limiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbrazo%2Frate_limiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbrazo%2Frate_limiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vbrazo","download_url":"https://codeload.github.com/vbrazo/rate_limiter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244261152,"owners_count":20424886,"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-10-13T14:39:01.826Z","updated_at":"2026-04-16T11:31:32.159Z","avatar_url":"https://github.com/vbrazo.png","language":"Ruby","readme":"# Rate Limiter for Rails APIs\n\n[![CircleCI](https://circleci.com/gh/vbrazo/rate_limiter.svg?style=svg\u0026circle-token=76a6a276549c313fa74076e5638a1d6d15cd5ee7)](\u003chttps://app.circleci.com/settings/project/github/vbrazo/rate_limiter\u003e)\n[![Gem Version](https://badge.fury.io/rb/rate_limiter_engine.svg)](https://badge.fury.io/rb/rate_limiter_engine)\n\nRate Limiter is a Rails engine that can easily limit requests per client in your Rails APIs.\n\n## Problem\n\nRate limiting is the act of limiting the number of requests sent to or from a system. It's most often used to limit the number of incoming requests in order to prevent `DoS attacks` and can be enforced at the IP-address level, at the user-account level, or at the region level, for example.\n\n#### DoS attack\n\nShort for \"denial-of-service attack\", a DoS attack is an attack in which a malicious user tries to bring down or damage a system in order to render it unavailable to users. Much of the time, it consists of flooding it with traffic. Some DoS attacks are easily preventable with rate limiting, while others can be far trickier to defend against.\n\n#### DDoS attack\n\nShort for \"distributed denial-of-service attack\", a DDoS attack is a DoS attack in which the traffic flooding the target system comes from many different sources (like thousands of machines), making it much harder to defend against.\n\n## Approach\n\nIn order to control the Rate Limiting, this Rails Engine proposes to use Redis and its in-memory key-value store. Redis offers some persistent storage options but is typically used as a really fast, best-effort caching solution. Redis is also often used to implement rate limiting.\n\n### Installation\n\n- Add this line to your application's Gemfile:\n\n```ruby\ngem 'rate_limiter_engine', 'X.Y.Z'\n```\n\nand run `bundle` to install your dependencies.\n\n- Create an initializer for your Rate Limiter engine and set the default properties:\n\n```ruby\nRateLimiter.configure do |config|\n  config.rate_default = 2\n  config.period_default = 2\n  config.force_rate_limit = 100\n  config.force_period = 2\nend\n```\n\n### Usage\n\nTo add a Rate Limiter, all you have to do is `include RateLimiter::RateLimit` in `ApplicationController` to have it on all your controllers using default settings of 100 request per hour (100 seconds).\n\nYou can also add it directly to the controller you want to be rate limited.\n\nTo customize, just use helper methods `rate` and `period`, as following:\n\n```ruby\nclass ApplicationController \u003c ActionController::Base\n  include RateLimiter::RateLimit\n\n  rate 100\n  period 100\n\n  …\nend\n```\n\n## Available Docker commands\n\nI built this engine with Docker so I'd suggest using it. All available commands are:\n\n| Command      | Description                            |\n|--------------|----------------------------------------|\n| make build   | Build the application                  |\n| make specs   | Run all the specs                      |\n| make bash    | access the bash inside the container   |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvbrazo%2Frate_limiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvbrazo%2Frate_limiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvbrazo%2Frate_limiter/lists"}