MongoDB Finishing Notes Performance monitoring

Source: Internet
Author: User

method One: Mongostat

This tool provides a quick view of statistics for a set of running MongoDB instances, using the following:

[[email protected] bin]#./% idx Miss% QR|QW ar| AW conntime *0 *0 *0 *0 ... 0 0 0|0 1|0 4 01:19:15*0 *0 *0 *0 ... 0 0 0|0 1|0 4 01:19:16*0 *0 *0 *0 ... 0 0 0|0 1|0 4 01:19:17

It refreshes the status value every second, providing good readability, which allows you to observe the performance of a whole.

Field Description:

Insert: Insertion amount per second
Query: Number of queries per second
Update: Volume per second
Delete: The amount of deletes per second
Locked: Lock Ration
QR | QW: Client Query Queue Length (read | write)
Ar | AW: Active Client Volume (read | write)
Conn: Number of connections
Time: Current

method Two: Db.serverstatus

This command is most commonly used

>Db.serverstatus () {"Host": "Localhost.localdomain","Version": "1.8.1",--Server version"Process": "Mongod","Uptime": 3184,--start time (seconds)"Uptimeestimate": 3174,"LocalTime": Isodate ("2012-05-28t11:20:22.819z"),"GlobalLock" : {"TotalTime": 3183918151,"LockTime": 10979,"Ratio": 0.000003448267034299149,"Currentqueue" : {"Total": 0,--Current Total queue volume"Readers": 0,--read request Queue Volume"Writers": 0--write request queue volume},"Activeclients" : {"Total": 0,--Current Total Client connection amount"Readers": 0,--client Read Request volume"Writers": 0--client write Request Volume}},"Mem" : {"Bits": 32,--32-bit system"Resident": 20,--The amount of material in use"Virtual": 126,--virtual amount of memory"Supported":true, --whether to support extended memory"Mapped": 32},"Connections" : {"Current": 1,--Current active Connection Volume"Available": 818--remaining idle connections},......"Indexcounters" : {"Btree" : {"Accesses": 0,--Index Access Amount"Hits": 0,--Index hit Volume"Misses": 0,--Index deviation Amount"Resets": 0,"Missratio": 0--Index deviation rate (not hit)}},......"Network" : {"Bytesin": 1953,--the amount of data sent to this server (in units:byte)"Bytesout": 25744,--the amount of data emitted by this server (in units:byte)"Numrequests": 30--The amount of requests sent to this server},"Opcounters" : {"Insert": 0,--amount of insert Operation"Query": 1,--The amount of query operations"Update": 0,--amount of update operation"Delete": 0,--The amount of the delete operation"Getmore": 0,"Command": 31--amount of other operations},......"OK": 1}>method Three: Db.stats db.stats view database status information>db.stats () {"DB": "Test","Collections": 7,--Number of collection"Objects": 28,--Number of Objects"Avgobjsize": 50.57142857142857,--average size of objects"DataSize": 1416,--Data Size"Storagesize": 31744,--data size (with pre-allocated space)"Numextents": 7,--Number of events"Indexes": 7,--Number of indexes"Indexsize": 57344,--Index Size"FileSize": 50331648,--File Size"OK": 1--This time take stats is normal}>
View Code

method Three: profile

MongoDB can monitor data through profile to optimize it. Check whether the profile function is currently turned on with Command Db.getprofilinglevel () returns level, value 0|1|2, meaning: 0 for close, 1 for record slow command,  2 for all Start profile function for Db.setprofilinglevel (level); #level等级, when the value is 1, the slow command defaults to 100ms and changes to Db.setprofilinglevel (LEVEL,SLOWMS) such as Db.setprofilinglevel (1,50) This changes to 50 milliseconds to view the current monitoring log through Db.system.profile.find ().

> Db.system.profile.find ({millis:{$gt:"ts": Isodate ("2011-07-23t02:50:13.941z"), "info": "Query Order.order reslen:11022 nscanned:672230  \nquery: {status:1.0} nreturned:101 bytes:11006 640ms "," Millis ": 640  "ts": Isodate ("2011-07-23t02:51:00.096z"), "info": "Query Order.order reslen:11146 nscanned:672302  \nquery: {status:1.0, User.uid: {$gt: 1663199.0}}  nreturned:101 bytes:11130 647ms "," Millis ": 647}

The meaning of the value here is

TS: Command Execution time

Info: Contents of the command

Query: Representative queries

Order.order: The Library and collection representing the query

Reslen: Returned result set size, byte number

nscanned: Number of scanned records

Nquery: The following is the query condition

Nreturned: Returns the number of records and the elapsed time

Millis: The time spent

If you find that time is longer, you need to optimize it.

For example, if the number of nscanned is large or close to the total number of records, then the index query may not be used.

The Reslen is large, and it is possible to return unnecessary fields.

Nreturned is very large, it is possible to query the time without adding restrictions.

MongoDB Finishing Notes Performance monitoring

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.