Performance: Rate limiting
HIGH IMPACT
Rate limiting controls how often users can make requests, affecting server load and response times.
class ApplicationController < ActionController::Base before_action :check_rate_limit def check_rate_limit if Redis.current.incr(user_rate_key) > 1000 render plain: 'Rate limit exceeded', status: 429 end end end
class ApplicationController < ActionController::Base before_action :check_rate_limit def check_rate_limit if request_count_for_user > 1000 render plain: 'Rate limit exceeded', status: 429 end end end
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| In-memory request counting | 0 | 0 | 0 | [X] Bad |
| Redis atomic counters for rate limiting | 0 | 0 | 0 | [OK] Good |