In my case, and it appears to be true for Spool too, I don't know what bit will be set first. It could be 12 or it could be 2938251, so to prevent a slowdown if the initial bit is a high place I use buckets of bitmaps, each holding around 8 million bits.
 Read Warning: http://redis.io/commands/setbit
For instance you want to set bit i, but you want k bits per every key, the you do:
keyname = "bitmap:"+(i/k)
keybit = i%k
var bucketSize = 8190;
var bucketNumber = Math.floor(userId / bucketSize),
bitInBucket = userId % bucketSize;
2 million users' actions could be tracked in 250k per metric. 10 metrics per day is 2.5m per day x 7 days is back to just over 16m (17.5m).
Redis has a mode which does this automatically I believe (and it's the default if I remember correctly).
I'm using MongoDB and IDs are 12-byte values of which the first four are a timestamp. Does anyone know of a way to make this method work, ideally without adding another field to the collection?
I hope it's clearer now.
Realtime Metrics with Redis: 128 Million Users + 16MB RAM = 50ms
Realtime Metrics for 128 Million Users with Redis: 50ms + 16MB RAM