DEV Community

afrazs
afrazs

Posted on

Device Limit like netflix

Hello All,

I need to know how to limit the number of devices my angular7(nodejs backend) program runs. I need to limit the devices and need a perfect solution like netflix. We already have a broader structure in amazon aws and can expend more on something that helps limiting the devices. Further, we can use amazon cognito as well but depends what solution you guys come up with.

Thanks

Top comments (3)

Collapse
 
nickholmesde profile image
Nick Holmes

Do you mean limit the number of devices per user, or just total devices?

Do you have some notion of active session? In your example of Netflix, the back-end implicitly knows it's streaming to a device.

Maybe if you describe your application a bit more, it would be possible to offer concrete suggestions.

Collapse
 
afrazs profile image
afrazs

Nick,

Thanks a lot for the reply.

I want to limit number of devices per user. Its not about streaming but its a simple MEAN stack application and we need to limit users' devices. Like 1 user can login to only 2 devices otherwise, we won't let them login.

Please let me know what suggestions you have or reply me for any questions further if above doesn't fulfill the requirement.

Thanks

Collapse
 
nickholmesde profile image
Nick Holmes

Right. So you have a couple of problems to solve. Firstly you need to be able to uniquely identify every device. This is not so easy, but there is an interesting and detailed paper on some approaches.

The next thing to solve is understanding when a user is (still) using a device. As HTTP is stateless, it can be hard to know if the user is still using your app or not. Unless you already have some notion of session, or a proxy for it, you will need to keep recording the last time you see any activity from the user, and then assume they are no longer using the device after, for example 30 minutes.

Then really is just a matter of putting these things together, and checking how many sessions are currently running of each users, when they authenticate.