0

I should build a web application to track users activities and I have some issues to understand how can use Redis for tracking online users activities and Mongo to store that data for analyzing it.

I could use just Mongo but I'm worried about the fact I have a lot of invocations to follow what a user is doing. So I was thinking to write on Redis the online data and put in Mongo when they become old. I mean old when the data is meaningless for being online.

I thought about one gateway between Mongo and Redis, so could be RabbitMQ?.

Any suggestions? I should use just Mongo?

Just an example of code I wrote:

Front-end (Angular application / Socket.io):

setInterval(function () {
   socket.emit('visitor-data', {
       referringSite: document.referrer,
       browser: navigator.sayswho,
       os: navigator.platform,
       page: location.pathname
   });
}, 3000);

Back-end ( Node.js/ Socket.io)

socket.on('visitor-data', function(data) {
    visitorsData[socket.id] = data;
);

VisitorsData is a just in an array, but I should build a scalable application, so I can't store data anymore in this way.

Then I have some functions like this for computing the data:

function computeRefererCounts() {

    var referrerCounts = {};
    for (var key in visitorsData) {
         var referringSite = visitorsData[key].referringSite || '(direct)';
         if (referringSite in referrerCounts) {
             referrerCounts[referringSite]++;
         } else {
             referrerCounts[referringSite] = 1;
         }
    }
    return referrerCounts;
}

Just some numbers: I estimated something like :

  1. 1 million users for day
  2. 15 million activities for day.
cirosomma
  • 71
  • 7

0 Answers0