I am trying to count the unique vistors per page or other events (like click etc ) etc for different clients. What I plan to do is assign a unique cookie based GUID and then for every event call SADD for the GUID. redis key will be SET_[ EVENTID ]
If I just wanted count of users I could probably use PFADD, but my app also needs to know who are the unique users
But problem is if there are too many EVENTs or too many users then SADD will end up with a lot of user ids in memory We are expecting 1000k+ user events every hour , across all clients and the number of events will also be 100+
I want an opinion is redis the correct storage choice. Any traditional RDBMS method does not work because of the sheer number of requests
I am not sure if any other storage can help like Aerospike
In RTB, where Aerospike is used heavily, frequency capping is a common use case for the Demand-Side Platforms (DSP). A cap is placed on the number of times a user sees a particular ad, or ads from a specific campaign. At the same time, the total number of impressions is tracked, along with the remaining budget. These counters typically have a short TTL.
Solution
You could use a composite key <page ID : user ID : yyyymmdd>
as a flag for whether a specific user had visited the page, with a 24h TTL. This would live in a set page-visit
in an in-memory, data-in-index namespace.
If there is no such key:
page-visit
with an initial value of 1.<page ID : yyyymmdd>
in the set page-users
. This set (page-users
) can live in a namespace that stores its data on SSD.If this key exists:
At the end of the day:
<page ID : yyyymmdd>
from the set page-users
users
set based on this list of user IDs.Advantages
page-visit
flag is very low latency. It uses very little memory, as data-in-index namespaces take no additional space past the 64B of metadata each object in Aerospike costs. For example, 10M users * 64B * replication-factor 2 = 1.2GB of DRAM.page-users
record. You only use this operation when a new unique user appears on the page (guarded by the page-visit
flag).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With