When your MongoDB instance encounters slow insertion query, you should first check the MongoDB running status.
Mongostat is a built-in MongoDB command, which is located in the MongoDB bin directory. Use:./mongostat, as shown in the figure below:
This is displayed under securecrt. By default, securecrt displays a small number of columns. If a line break occurs, choose Options> Global Options> adjust the maximum column to 150.
Meanings of various indicators:
- Inserts/s insert times per second
- Query/s queries per second
- Update/s updates per second
- Delete/s Delete times per second
- Getmore/S: Number of getmore executions per second
- Command/s number of commands per second, such as Count
- The number of times flushs/s executes fsync to write data to the hard disk per second.
- All MMAP data volumes of mapped/s, in MB,
- Vsize virtual memory usage, in MB
- Res physical memory usage, in MB
- Faults/s: The number of access failures per second (only available in Linux). Data is swapped out of the physical memory and placed in swap. Do not exceed 100; otherwise, the machine memory is too small, resulting in frequent swap writes. In this case, you need to upgrade the memory or expand
- Locked % The percentage of lock time. Try to keep it below 50%.
- Idx Miss % index Miss percentage. If the index is too high, check whether the index is missing.
- Q t | r | w when MongoDB receives too many commands and the database is locked and cannot be executed, it adds the commands to the queue. This column shows the length of the total, read, and write queues. If they are all 0, Mongo is under no pressure. When the concurrency is high, the queue value usually increases.
- Current number of conn connections
- Time Timestamp
MongoDB good run labels:
The insert query update delete operation is relatively stable. The larger the four columns of data, the higher the performance. If the index decreases sharply after a certain period of time, it indicatesProgramSolve the problem.
The smaller the faults, the better. The smaller the faults, the lower the operation failure rate;
The smaller the idx miss, the better. The smaller the index miss, the higher the index hit rate. MongoDB indexes are very important;
The larger the netin/netout data, the better. The larger the data exchange is.