Your web site, application, or file hosting service has finite network and server resources available to it to serve all its users. One of the most important resources is bandwidth. Substantial bandwidth consumption by only a subset of the user base can result in network congestion and reduced resource availability to other users. To prevent network congestion, you might have to limit a client’s bandwidth consumption by using temporary service denial techniques such as responding to a client request with an HTML page if it has exceeded a preconfigured bandwidth value over a fixed time period leading up to the request.
In general, you can regulate bandwidth consumption either per client device or per user. This use case demonstrates how you can limit bandwidth consumption per client to 100 MB over a time period of one hour. The use case also demonstrates how you can regulate bandwidth consumption per user to 100 MB over a time period of one hour, by using a custom header that provides the user name. In both cases, the tracking of bandwidth consumption over a moving time period of one hour is achieved by setting the interval parameter in the stream identifier to 60 minutes. The use cases also demonstrate how you can import an HTML page to send to a client that has exceeded the limit. Importing an HTML page not only simplifies the configuration of the responder action in these use cases, but also simplifies the configuration of all responder actions that need the same response.
In the command-line interface, perform the following tasks to configure action analytics for limiting a client’s or user’s bandwidth consumption. Each step includes sample commands and their output.
> add lb vserver mysitevip HTTP 192.0.2.17 80 Done > add service service[1-10] 192.0.2.[240-249] HTTP 80 service "service1" added service "service2" added service "service3" added . . . service "service10" added Done > bind lb vserver vserver1 service[1-10] service "service1" bound service "service2" bound service "service3" bound . . . service "service10" bound Done
> add stream selector myselector CLIENT.IP.SRC Done
> add stream selector myselector HTTP.REQ.HEADER(“UserHeader”) Done
> add stream identifier myidentifier myselector -interval 60 -sampleCount 1 -sort BANDWIDTH Done
> import responder htmlpage http://192.0.2.20:80/stdpages/wait.html crossed-limits.html This operation may take some time, Please wait... Done > add responder action crossed_limits respondwithhtmlpage crossed-limits.html Done
> add responder policy myrespol1 'ANALYTICS.STREAM("myidentifier").COLLECT_STATS' NOOP Done > add responder policy myrespol2 'ANALYTICS.STREAM("myidentifier").BANDWIDTH.GT(1048576)' crossed_limits Done
> bind lb vserver mysitevip -policyName myrespol1 -priority 1 -gotoPriorityExpression NEXT Done > bind lb vserver mysitevip -policyName myrespol2 -priority 2 -gotoPriorityExpression END Done
> stat stream identifier myidentifier -sortBy BandW –fullValues Stream Session statistics Req BandW 192.0.2.30 5000 3761 192.0.2.31 29 2602 192.0.2.32 25 51 RspTime Conn 192.0.2.30 2 0 192.0.2.31 0 0 192.0.2.32 0 0 Done >