High MongoDB Lock Percentage

by Nate Coppinger on November 13, 2019
MongoDB Multi-granular Locking System

Are you experiencing high queues or slow response times in your MongoDB database? Well then, you may have a deeper issues within your database… a high MongoDB Lock Percentage. MongoDB can be a large and complicated database to manage and maintain, which means you will probably have multiple team members accessing and working on data at the same time. MongoDB employs a multi-granular lock system that allows users to concurrently work in the database and view the same data without making conflicting modifications. This Multi-granular locking system locks MongoDB and stops users from writing on it, when someone else is reading or writing, and vice-versa. However it does not lock the database when two or more users are reading simultaneously. MongoDB tracks how often your database is locked with a “Lock Percentage” metric. This percentage is calculated on two separate levels, “database” and “global”. On the “database” level, MongoDB will lock two concurrent users from working on the same database, but will not lock two users on separate databases unless there is a global rule put in place to lock one system when another related one is being used.

High MongoDB Lock Percentage, MongoDB, Lock Percentage, Lock
What is an Average MongoDB lock Percentage?

If your database is a read-only system, where most users won’t be modifying data on a regular basis, then you should expect a low MongoDB lock percentage, somewhere around 10%. A write database may have an average lock percentage of around 20% but can even exceed 60%. Even in a write-heavy database environment where you often have multiple users working on the data concurrently, you will still want to keep your lock percentage as feasibly low as possible. 

High MongoDB Lock Percentage, MongoDB, Lock Percentage, Lock, metrics, KPI, Database, Global
Find the Root Cause

A high lock percentage may be the root cause of other issues that you are experiencing in your MongoDB database. When you have a high locking percentage, you may experience slower response and application call times, high queues, increased replication lag, high CPU usage, and even failures. To ensure that none of these issues occur and you minimize your MongoDB lock percentage, we recommend that you set up a monitoring system, such as Google Stackdriver or New Relic, to make sure the lock percentage does not exceed your set limits. To ensure your lock percentage is within the optimal threshold, you may also want to set up alerts to help monitor other key performance indicators with metrics such as: write tickets, available read and write tickets, intent exclusive lock times, and many more. Monitoring these metrics should help you stay on top of everything, and understand why your MongoDB lock percentage may be so high. 

High MongoDB Lock Percentage, MongoDB, Lock Percentage, Lock, metrics, KPI, Dashboard, BindPlane
Stream MongoDB metrics with BindPlane

BindPlane can stream MongoDB metrics and logs to your data monitoring service of choice, and if you already use Google Stackdriver you can use BindPlane for no extra cost. Read this blog to learn how to configure and deploy MongoDB within BindPlane so you can begin monitoring your MongoDB lock percentage and other KPIs. 

Get started

Try BindPlane for free. No credit card required.

Sign up
True Visibility
BindPlane for VMware vRealize Operations

True Visibility allows cloud management teams to use VMware vRealize’s powerful machine learning and capacity planning engine across their entire hybrid cloud environment.

Azure Monitor...everything
BindPlane for Microsoft Azure Monitor

Make Azure Monitor your first-pane-of-glass across your entire multi-cloud, multi-database or hybrid platform environment.

Thank you for contacting us. Your information was received. We'll be in touch shortly.