2020 02 08
- WEEKLY
Cover Photo: 國家戲劇院 戲台咖-戲台酒館
Technology MongoDB MongoDB Indexes and Performance
mongotop mongostat Indexing and MongoDB Query Performance Analyze Query Performance
Troubleshooting MongoDB 100% CPU load and slow queries db.currentOp({“secs_running”: {$gte: 3}}) cursor.explain(“executionStats”) 可以看該次查詢的使用到的 Index、總共翻找多少筆資料,對於分析效能瓶頸時很有幫助。
Read Preference Read Concern MongoDB Replica Sets 讀資料時預設從 primary 讀,寫當然也是從 primary 寫,所以在讀寫量大的時候,會看到 primary 非常忙碌,但是其他 secondary 卻很悠哉。
Application 可以修改 Connection String,加上 readPreference 參數,如果指定 readPreference=secondary,則是設定只會從 secondary 讀取資料,若所有 secondary 都掛掉了就會讀取失敗。