More on Request Limiting

Continuing with my coverage of check-request-limits (see request limiting and concurrency limiting), today I'll give a few examples using the <If> tags introduced in Web Server 7.0.

As I showed in the previous articles, using server variables with the monitor parameter can be quite flexible. However, there are times when you may want to apply check-request-limits in ways which cannot be expressed using monitor parameter values. Check out the <If> expressions also introduced in Web Server 7.0.

Let's look at an example. Say you want to apply limits only to request paths which end in \*.jsp. You could write:

<If $path = "\*.jsp">
PathCheck fn="check-request-limits" max-rps="10"
</If>

Simple enough! There are some pitfalls to watch out for, though. Take a look at this example:

<If $path = "\*.pl">
PathCheck fn="check-request-limits" max-rps="100"
</If>
<If $path = "\*.jsp">
PathCheck fn="check-request-limits" max-rps="10"
</If>

At first glance one might think this limits all "\*.pl" paths to 100rps and all "\*.jsp" paths to 10rps. Not so! Recall that request counts and averages are tracked separately for each value of the monitor parameter (thus, for example, when monitor="$ip" counts are kept separately for every client IP). In the above two invocations of check-request-limits there are no monitor parameters. So where are the counts kept? When the monitor parameter is not given, counts are kept in a default unnamed slot.

By now you can probably see the issue... the counts for the two calls above are kept in the same counter. So, whenever a "\*.pl" request is processed, the counter increases. But this same counter is the one used for "\*.jsp" requests! If the server is processing an average of 20rps worth of "\*.pl" requests, no request for "\*.jsp" will ever be serviced... Not quite what I wanted!

Fortunately, this is easy to correct by simply tracking each type of request separately, using the monitor parameter:

<If $path = "\*.pl">
PathCheck fn="check-request-limits" max-rps="100" monitor="pl"
</If>
<If $path = "\*.jsp">
PathCheck fn="check-request-limits" max-rps="10" monitor="jsp"
</If>


Comments:

Post a Comment:
Comments are closed for this entry.
About

jyri

Search

Top Tags
Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today