How to use MongoDB profiler

Search for a command to run...

No comments yet. Be the first to comment.
Here's the TLDR. Create a file to where all the methods will be present. // s3.js import * as AWS from '@aws-sdk/client-s3'; const bucket = process.env.AWS_BUCKET_NAME; const region = process.env.AWS_REGION; const endpoint = process.env.AWS_ENDPOIN...
Uploading file to google drive requires the following steps: Authenticate with google drive Uploading a file to a specific folder by the name of the folder If the folder does not exist, we need to create the folder first Finally, upload the file....
While naming variables, functions and classes is one of the hardest things to do as a programmer, writing comments is also hard. It’s easier to express our logic in code vs English. Let’s look at the best ways to write comments in code. YAGNI — You a...

With an increasing number of users using google sheets to maintain data, it has become essential to access google sheets in your development environment. You have a few options: Use API from services like sheetsu, sheety, etc Use Official Google sh...

Back in my previous company, we ran into issues where our MongoDB server became very slow and affected all our queries. Fortunately, we used Atlas and Profiler was available to us to analyse what was going on.
Here are some things we looked at.
High Operation Time
Recurring DB queries
CPU Usage
Aggregation Pipelines
Performance Advisor for recommended indexes (Though, it might not be useful every time)
After looking at the metrics, we reduced recurring DB queries by adding a caching layer in between, since the data changed less frequently than the expensive queries we were making.
First, we added an index to a couple of fields which were actively being used in our pipelines.
Second, we improved the performance of the pipeline by moving our $match filter state before the lookup to reduce the amount of lookups.
Finally, we used $project to limit the amount of data we passed from one stage to another.
We also had to increase the CPU and RAM of our infra to handle the increased volume of queries being made to the DB as our last step.