MongoDB Diagnostics and Debugging (Version 3.4)
Ch 4: Connectivity
What Connectivity Issues Look Like in an Application
- Time Outs
- Connection Error
- Incorrect URI
- Non-static IP Addresses
- Firewall
- Out of conrtrol
- DDoS attacks
- ISP Performing Poorly
Timeout
Timeout Errors
- Server Selection TimeoutError
- WTimeError ( 僅表示 writeConcern 沒有在時間內完成,不代表 query 沒有完成 )
Closing and Dropping Connections
- Greedy Connection Applications
- Implication of Connection in Memory allocation
- How to detect poorly configured hosts
- Election of new Primary
- Mongostat
- db.serverStatus()
- free -h (OS)
- mongod log file
MongoDB allows incoming connections up to 65536.
Since our process require RAM, too many connections is not the normal behavior for a well written application.
- net.maxIncomingConnections configuration file parameter affect the number of available incoming connections
- Cuz one connection is regard as a file to mongod, we need to set higher limit for more connections.
Election of Primary
Write Concern and Timeouts
Doc
Replica set with 'w:majority' may have some bad situation when there are arbiters or delay servers in the set.
Hostnames and Cluster Configuration
edit host file
Networking Best Practices
- All Replica Set nodes should be addressable from client hosts and replica set hosts
- All mongos nodes should be addressable
- Use DNS names instead of IP address to avoid IP address renew resolution conflicts
- Make use of ping command to check if node can reach each other
- Use telnet to make sure that the ports are available
Sharding Issues
split chunk manually
Increase chunk size
MongoDB Diagnostics and Debugging (Version 3.4)
Ch 5: Schema Issues
Schema Investigation
- turn on the profiler
- turn off the profiler and see how many queries were made
- Get deeper information