# MongoDB 4

This page describes the Optimization Pack for MongoDb version 4.x.

## Metrics

### Document operations

| Name                         | Unit        | Description                                                    |
| ---------------------------- | ----------- | -------------------------------------------------------------- |
| mongodb\_document\_deleted   | documents/s | The average number of documents deleted per second             |
| mongodb\_documents\_inserted | documents/s | The average number of documents inserted per second            |
| mongodb\_documents\_updated  | documents/s | The average number of documents updated per second             |
| mongodb\_documents\_returned | documents/s | The average number of documents returned by queries per second |

### Other metrics

| Name                                  | Unit        | Description                                                                                                                       |
| ------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------- |
| mongodb\_connections\_current         | connections | The current number of opened connections                                                                                          |
| mongodb\_heap\_used                   | bytes       | The total size of heap space used (only available in Linux/Unix systems)                                                          |
| mongodb\_mem\_used                    | bytes       | The total amount of memory used                                                                                                   |
| mongodb\_page\_faults\_total          | faults/s    | The average number of page faults per second (i.e., operations that require MongoDB to access data on disk rather than on memory) |
| mongodb\_global\_lock\_current\_queue | ops         | The current number of operations queued because of a lock                                                                         |

## Parameters

### Cache

| Name                              | Unit       | Type    | Default                                                                                                                                         | Domain                                                                                                                                          | Restart | Description                                                                                                                     |
| --------------------------------- | ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------- |
| mongodb\_cache\_size              | megabytes  | Integer | You should select your own default value when you create a study, since it is highly dependent on your system (how much memory your system has) | You should select your own default value when you create a study, since it is highly dependent on your system (how much memory your system has) | No      | The maximum size of the internal cache that MongoDB (WiredTiger) will use to operate                                            |
| mongodb\_eviction\_trigger        | percentage | Integer | 95                                                                                                                                              | 1 → 99                                                                                                                                          | No      | The percentage threshold on the use of the MongoDB cache for which cache eviction will start and client threads will throttle   |
| mongodb\_eviction\_target         | percentage | Integer | 80                                                                                                                                              | 1 → 99                                                                                                                                          | No      | The target percentage usage of the MongoDB cache to reach after evictions                                                       |
| mongodb\_eviction\_dirty\_trigger | percentage | Integer | 20                                                                                                                                              | 1 → 99                                                                                                                                          | No      | The percentage threshold on the use of MongoDB dirty cache for which cache eviction will start and client threads will throttle |
| mongodb\_eviction\_dirty\_target  | percentage | Integer | 5                                                                                                                                               | 1 → 99                                                                                                                                          | No      | The target percentage usage of the MongoDB dirty cache to reach after evictions                                                 |
| mongodb\_eviction\_threads\_min   | threads    | Integer | 4                                                                                                                                               | 1 → 20                                                                                                                                          | No      | The minimum number of threads to use to perform cache eviction                                                                  |
| mongodb\_eviction\_threads\_max   | threads    | Integer | 4                                                                                                                                               | 1 → 20                                                                                                                                          | No      | The maximum number of threads to use to perform cache eviction                                                                  |

### Other parameters

| Name                 | Unit    | Type    | Default | Domain      | Restart | Description                                                                                    |
| -------------------- | ------- | ------- | ------- | ----------- | ------- | ---------------------------------------------------------------------------------------------- |
| mongodb\_sync\_delay | seconds | Integer | 1min    | 1min → 6min | no      | The temporal interval between fsync operations where mongod flushes its working memory to disk |

## Constraints

Here are some constraints on parameters of MongoDB 4 that avoid common errors in the configuration of a MongoDB deployment:

| Constraint                                                         |
| ------------------------------------------------------------------ |
| mongodb\_eviction\_threads\_min <= mongodb\_eviction\_threads\_max |
| mongodb\_eviction\_dirty\_target <= mongodb\_eviction\_target      |
| mongodb\_eviction\_dirty\_trigger <= mongodb\_eviction\_trigger    |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.akamas.io/akamas-docs/3.3.1/akamas-reference/optimization-packs/mongodb-pack/mongodb-4.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
