Skip to content

Commit befecad

Browse files
authored
Merge pull request #2909 from sciencehistory/stop_tracking_informational_rate_limits
Stop logging "informational" rate limits
2 parents bc0b8d4 + 71e0c1e commit befecad

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

config/initializers/rack_attack.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
# But we're going to try a more generous 3 per second over
3030
# 1 minute instead.
3131
#
32-
# May 1 2024: Limiting much more extensively to 30 req per minute -- one per every two seconds
33-
# averaging over a minute -- after bot attacks costing us money from s3.
3432
Rack::Attack.throttle('req/ip', limit: 180, period: 1.minutes) do |req|
3533
# On heroku, we may be delivering assets via rack, I think.
3634
# We also try to exempt our "api" responses from rate limit, although
@@ -44,12 +42,6 @@
4442
)
4543
end
4644

47-
# But we're also going to TRACK at half that limit, for ease
48-
# of understanding what's going on in our logs
49-
Rack::Attack.track("req/ip_track", limit: 90, period: 1.minute) do |req|
50-
req.ip unless req.path.start_with?('/assets')
51-
end
52-
5345
# And we want to log rack-attack track and throttle notifications. But we get
5446
# a notification every time an IP has exceeded the limit -- that's far too
5547
# many to log every time, could be many per second when it's exceeding limits.
@@ -73,8 +65,8 @@
7365
rack_env = rack_request.env
7466
match_name = rack_env["rack.attack.matched"]
7567

76-
# only log here for our `req/` throttles and tracks above, not our other ones such as bot detect
77-
next unless match_name.start_with?("req/")
68+
# only log here for our `req/` throttle above, not our other ones such as bot detect
69+
next unless match_name == "req/ip"
7870

7971
match_data = rack_env["rack.attack.match_data"]
8072
match_data_formatted = match_data.slice(:count, :limit, :period).map { |k, v| "#{k}=#{v}"}.join(" ")

0 commit comments

Comments
 (0)