Ihor Rusyn <0k.a.b...@gmail.com> wrote:

> Today, I tested your product (cluebringer v2.0.14 and v2.1.x). And I
> found that Quota module works incorrectly on both versions for me.

...

> After sending 5 messages, policyd blocks access (as expected). But few
> minutes later, after the event in log "DEBUG: Shutting down caching
> engine (xxxx)" , I can send 1 message again, please see log:

That sounds like correct operation - without wading through the logs, I'm not 
sure of the timing.
Your quota is 5 messages/hour - or about one message every 12 minutes. But it's 
not as simple as max 5 messages in any a 3600s period.

The way quotas work is :
When a message is passed in, the counter is adjusted.
If the counter is over-quota then the message is blocked.
Else the message is passed, and 1 is added to the counter for each recipient.

But the trick is, the counter is reduced with time - like a leaky bucket. The 
actual calculation is C=C-(Q*dT/QT) where C is the counter, Q is the quota (5 
here), dT is the time interval since the quota was last adjusted, and QT is the 
time period for the quote (3600s here).

So to start with, your counter is 0. You can get 6 messages out in a short time 
- the first 5 take the counter up to 5 or less, then the 6th takes the counter 
over quota. If you sent all 6 messages in one instant, the counter would go to 
6. After 12 minutes, the counter will have "leaked down" by 1 and you can send 
another message, after another 12 minutes you can send another message, and so 
on. So if you just keep trying, you'll get one message through roughly once 
every 12 minutes.

If you stop sending messages, then after an hour the counter will have gone 
down to 0. You can now burst out another 6 messages.

So you can burst up to the quota, but will then be limited to the message rate 
you were probably expecting. Long term, you will be limited to the rate you've 
configured.

So 5 messages/3500s is the same rate as 10 per 7200s or 120 per 86000s (24hr). 
All will allow you 120 messages/day - the difference is the burst rate - if the 
counter is at zero, then you can burst 6, 11, or 121 messages respectively 
before the rate limiting kicks in.


_______________________________________________
Users mailing list
Users@lists.policyd.org
http://lists.policyd.org/mailman/listinfo/users_lists.policyd.org

Reply via email to