You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Evans Ye <ev...@apache.org> on 2017/02/11 03:00:40 UTC

Ignite for fine-grained policy/quota control

Hi Igniters,

We recently are using Ignite building a real-time notification system.
Ignite plays a crucial part on policy control for notifications. For
example, we would like a user who has a quota of 100 notifications per day
gets 100 messages per day precisely. Once quota exceeded, Further
notifications should be dropped.

The way we are trying to implement this is to use IgniteCache with the key
to be user id and the value to be a counter. Since the system is
distributed, we also adopt Ignite distributed lock to make sure every
read/write on the counter(quota) is correct.

Do you think this is the right way to use Ignite, or there are better
solutions?

Best,
Evans Ye

Re: Ignite for fine-grained policy/quota control

Posted by vkulichenko <va...@gmail.com>.
Evans,

If you need to atomically update multiple counters, then you indeed need
locks or transaction. If both are applicable, I would recommend using
transactions.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-for-fine-grained-policy-quota-control-tp10563p10613.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite for fine-grained policy/quota control

Posted by Evans Ye <ev...@apache.org>.
I have considered using AtomicLong as well. But the main reason to
introduce ignite lock is becuase the increaseAndGet() method should only be
called after all the policies are allowed.

Here is an example, when a message is allowed by Policy A(100 messages per
user per day), but blocked by policy B(500 messages per user per week),
nether counter A and counter B should have count increased.

Hence, my thought using ignite lock:
1). lock all used keys in policies
2). exam policies
3). If allowed, update counters
4). Unlock all used keys

Would transaction help in my case?

vkulichenko <va...@gmail.com>於 2017年2月13日 週一,上午10:33寫道:

> Hi Evans,
>
>
>
> It sounds like you can simply use AtomicLong:
>
> https://apacheignite.readme.io/docs/atomic-types
>
>
>
> -Val
>
>
>
>
>
>
>
> --
>
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Ignite-for-fine-grained-policy-quota-control-tp10563p10584.html
>
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>
>

Re: Ignite for fine-grained policy/quota control

Posted by vkulichenko <va...@gmail.com>.
Hi Evans,

It sounds like you can simply use AtomicLong:
https://apacheignite.readme.io/docs/atomic-types

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-for-fine-grained-policy-quota-control-tp10563p10584.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.