ActionLimiter
Provides Redis backed rate limiting for Rails applications.
Installing
gem install actionlimiter
bundle add actionlimiter
Usage
Set Redis URL
Rails.application.configure do |config|
config.redis = { url: 'redis://localhost:6379/0' }
end
Rails IP Middleware
Rails.application.configure do |config|
# Limit a single IP to 20 requests in a 5 second period.
config.middleware.use(ActionLimiter::Middleware::IP, period: 5, size: 20)
end