Mongodb – Close MongoDB dead connections

mongodb

I have a script that connects to my local mongos and do some processing. However, during the process, I encountered many cursor timeout exceptions, which (I suspected) left many dead connections on my server.

When I run mongostat on my host, I see 450+ connections:

insert  query update delete getmore command  vsize    res faults  netIn netOut  conn repl       time 
     0      0      0      0       0       1   977m   195m      0    62b   726b   458  RTR   02:11:07 
     0      0      0      0       0       1   977m   195m      0    62b   726b   458  RTR   02:11:08 
     0      0      0      0       0       1   977m   195m      0    62b   726b   458  RTR   02:11:09 
     0      0      0      0       0       1   977m   195m      0    62b   726b   458  RTR   02:11:10 

How can I make sure that these are idle resources that I should free up? If they are, how can I free them?

Best Answer

This should be taken care programmatically. Programmers have to close the connection whenever they are done with dB access else memory leaks could happen.
I'm not sure how these processes can be killed as an admin.