How can I see all logged in users?

On the Server how do I keep record or access records of logins and tokens etc

Make a collection, or a field in users collection where u will store array of login times

Yeah ? Okay thanks . Any other way?

Ask google or read some book


This is for active sessions if you are using any publications etc, which could be more telling regarding active load.

Otherwise you create an audit type collection and log events for signing in and out, or when other actions happen. If you use only inserts to log actions, instead of updates, you can use the event sourcing/cqrs type methodology to see more useful timelines and behaviors.

On the server look at ‘Meteor.onConnection’ for even anonymous user interactions, and ‘Accounts.onLogin’ and other event handlers for authenticated users, if using the Accounts module.

In production (not using meteor) we switched to a more scalable solution using envoy/kubernetes where all network requests go through a dedicated auth service running on it’s own set of containers. That service approves/denies based on different parameters, then writes the details to a database as they come through, without slowing down requests.

I wouldn’t use any kind of array updates on a document, if storage is an issue you can create a collection with expiring documents to retain only x days etc. Make sure to add basic indexes on user id, timestamp fields, or connection id etc to improve queries.

1 Like