Menu

Help with if/then ruleset

2020-05-14
2020-06-19
  • Craig Schneider

    Craig Schneider - 2020-05-14

    I am trying to find a way to do the following:
    IF an IP/Client makes more than 100 requests in 60 seconds, THEN throttle them back to 1 a second for 5 min.

    I am using QS_ClientEventLimitCount for the IF clause, but not finding a way to do the THEN clause.

     
  • Pascal Buchbinder

    I haven't tetsted this, but it could proably be configured like this:

    ## clients which perform more than 100 requests within 60 seconds trigger the request throttling
    # 1) count every request using a one minute counter/timer
    QS_SetEnv RequestsWithin60Seconds 1
    QS_ClientEventLimitCount 10000 60 RequestsWithin60Seconds
    # 2) limit reached if >99
    QS_SetEnv RequestsWithin60Seconds_LIMIT 99
    QS_SetEnvIfCmp RequestsWithin60Seconds_Counter gt RequestsWithin60Seconds_LIMIT Throttling=1
    
    ## Client hit the 100/60 limit and is now slowed down
    # 3) start a 5 minutes counter/timer
    QS_ClientEventLimitCount 10000 300 Throttling
    # 4) starts when hitting the 5 minute "Throttling"
    QS_SetEnv Throttling_LIMIT 0
    # 5) by adding a delay (60'000 milliseconds) and serializing the requests
    QS_SetEnvIfCmp Throttling_Counter gt Throttling_LIMIT QS_Serialize=1
    QS_SetEnvIfCmp Throttling_Counter gt Throttling_LIMIT QS_Delay=60000
    QS_ClientSerialize
    
    # 6) because we slow the client down so much, we should also limit the number of concurrent requests
    QS_SetEnvIfCmp Throttling_Counter gt Throttling_LIMIT QS_EventRequest=1
    QS_ClientEventRequestLimit 10
    
     

    Last edit: Pascal Buchbinder 2020-05-29

Log in to post a comment.