Reputation: 959
I am developing an application with online users list. For now I have global variable defined in nodejs
var onlineUsers = {}
which contains user objects
var userObj = {
username: 'johndoe',
fullname: 'John Doe',
user_id: 234242
}
that are online.
My question is, would it be better for performance, to put that online user objects in Redis or it can stay as is, considering potential scenario that it will be millions of online users?
Upvotes: 1
Views: 297
Reputation: 5385
When your potential scenario is millions of concurrent online users, you'll need to run multiple webservers to serve that load. Each webserver will need to record who has logged in and logged off in a shared datastore, in your case Redis.
Performance wise, storing it in local memory will be the fastest, but not scalable at all.
If you just started out developing this site, the in memory solution might be acceptable so you can focus on implementing product features and do the scalable Redis solution later. Especially if you only need Redis for this single feature.
Upvotes: 1