shlogg · Early preview
Jetthoughts Dev @jetthoughts

Ruby On Rails 7.2: Built-in Rate Limiting With Redis And Kredis

Ruby on Rails 7.2 adds built-in rate limiting to Action Controller using Redis & Kredis for easy abuse prevention & traffic management.

Ruby on Rails 7.2 added rate limiting to Action Controller. It's cool and easy to use.


  
  
  What's New?

Rails now offer built-in rate limiting using Redis and Kredis. This empowers you to control how often a user can act within a given time, putting you in the driver's seat.

  
  
  Before:


# Manually implemented rate limiting

    
    

    
    




  
  
  After:


class SessionsController < ApplicationController
  rate_limit to: 10, within: 3.minutes, only: :create
end
class SignupsController < ApplicationController
  rate_limit to: 1000, within: 10.seconds, by: -> { request.doma...