0

I am making a pet-project in MERN stack where I want to implement the activity status of users. After 3 minutes of inactivity the user status becomes inactive. One approach i am considering is by node-cron schedular

  • Users will have activity status and last seen in their schema and schedular will run every 3-4 minutes and fetches all users with last seen greater than 3 minutes and mark them inactive and a middleware to mark the user active whenever a request is made and update the last seen.

The problem is I think this will be a huge overhead to fetch all users after every 3-4 minutes and change their status resulting in ineffeciency of server.

Please suggest me if this is good approach or how to make it effecient and also if their is some better approach i should go for?

1 Answer 1

0

Instead of fetch and mark to inactive. simply write direct update query on users to check users active 3min ago and mark to inactive.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.