Skip to content

Rails request throttling just half the given limit #594

Description

@adityappc

Hey, I want to throttle my rails api request to 10 requests per minute. Following is the configuration I have set:

Rack::Attack.throttle("throttle_aggregate_data_per_min", limit: 10, period: 60) do |request|
  if request.path == "/v2/aggregate_data"
    get_client_id(request)
  end
end

below is the tracking configuration I have set:

Rack::Attack.track("throttle_aggregate_data_per_min", limit: 10, period: 60) do |request|
  if request.path == "/v2/aggregate_data"
    get_client_id(request)
  end
end

somehow I am able to send just 5-6 requests every minute as opposed to 10 requests that should be allowed.

rack-attack version -> 6.5
config.cache_store = :redis_store

Can someone help me what I am doing wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions