Skip to content

Commit

Permalink
Merge pull request #4319 from sul-dlss/relax-limits
Browse files Browse the repository at this point in the history
Relax rack-attack limits now that we're using metrics across all nodes.
  • Loading branch information
jcoyne authored Jul 10, 2024
2 parents daf86e3 + e267d9f commit bff8b4b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions config/initializers/rack_attack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
if Settings.THROTTLE_TRAFFIC
Rack::Attack.cache.store = ActiveSupport::Cache::RedisCacheStore.new(url: Settings.throttling.redis_url) if Settings.throttling.redis_url

Rack::Attack.throttle('req/search/ip', limit: 10, period: 1.minute) do |req|
Rack::Attack.throttle('req/search/ip', limit: 15, period: 1.minute) do |req|
route = begin
Rails.application.routes.recognize_path(req.path) || {}
rescue StandardError
Expand All @@ -27,12 +27,12 @@
req.ip if route[:controller] == 'catalog' && (route[:action] == 'index' || route[:action] == 'facet')
end

Rack::Attack.throttle('req/view/ip', limit: 300, period: 5.minutes) do |req|
Rack::Attack.throttle('req/view/ip', limit: 500, period: 5.minutes) do |req|
req.ip if req.path.start_with?('/view')
end

# Throttle article searching more aggressively
Rack::Attack.throttle('articles/search/ip', limit: 30, period: 5.minutes) do |req|
Rack::Attack.throttle('articles/search/ip', limit: 50, period: 5.minutes) do |req|
route = begin
Rails.application.routes.recognize_path(req.path) || {}
rescue StandardError
Expand All @@ -42,7 +42,7 @@
req.ip if route[:controller] == 'articles' && route[:action] == 'index'
end

Rack::Attack.throttle('articles/view/ip', limit: 300, period: 5.minutes) do |req|
Rack::Attack.throttle('articles/view/ip', limit: 500, period: 5.minutes) do |req|
route = begin
Rails.application.routes.recognize_path(req.path) || {}
rescue StandardError
Expand All @@ -52,7 +52,7 @@
req.ip if route[:controller] == 'articles' && route[:action] == 'show'
end

Rack::Attack.throttle('req/actions/ip', limit: 10, period: 1.minute) do |req|
Rack::Attack.throttle('req/actions/ip', limit: 15, period: 1.minute) do |req|
route = begin
Rails.application.routes.recognize_path(req.path) || {}
rescue StandardError
Expand Down

0 comments on commit bff8b4b

Please sign in to comment.