Ganu
Ganu

Reputation: 559

MongoDB: Checking number of users using my applications currently which is connected to my MongoDB server.

Is it possible to Check the number of users using my applications currently which is connected to my MongoDB server? Is there any command to find it? Also in the below output db.serverStatus().connections { "current" : 12, "available" : 807, "totalCreated" : NumberLong(96385) }

the current connection will include the number of users connected to my database through my application? Please explain. Thanks in advance!!!!

Upvotes: 1

Views: 619

Answers (1)

Nidhin David
Nidhin David

Reputation: 2474

db.serverStatus().connections shows the number of connections made to the MongoDB. But to find the number of users using the DB, you must absolutely know the number of connections a single client(user) will open. That means if your application opens 3 connections for single user then you cannot say there are 3 users. You can only say 3 connections are used, so there is only one user.

So you must first define a fixed amount of db connections for a single user.

Remember: unlike MySql, MongoDB is not intended to be directly used with a client. MongoDB is best when used along with a REST server. That means the client first connects to REST server and the DB is handled by the REST server and not the client directly.

Upvotes: 2

Related Questions