From 4a9a4380ceaeef988fc1a5fbdd03c3550288fe7d Mon Sep 17 00:00:00 2001 From: Denis Savitskiy Date: Wed, 24 Apr 2024 16:09:22 +0300 Subject: [PATCH] Change limit for /companies to 4 from 10 (300ms timeout for fetch) --- config/initializers/rack_attack.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/config/initializers/rack_attack.rb b/config/initializers/rack_attack.rb index b9d7a58..4fa3d5c 100644 --- a/config/initializers/rack_attack.rb +++ b/config/initializers/rack_attack.rb @@ -1,10 +1,6 @@ -Rack::Attack.throttle("requests by ip", limit: 5, period: 2) do |request| - request.ip -end +Rack::Attack.throttle('requests by ip', limit: 10, period: 2, &:ip) # Throttle query for companies filter to 10 reqs/sec -Rack::Attack.throttle('limit query for companies filter', limit: 10, period: 1) do |request| - if request.path == '/companies' && request.get? - request.ip - end +Rack::Attack.throttle('limit query for companies filter', limit: 4, period: 1) do |request| + request.ip if request.path == '/companies' && request.get? end