Madhu
Madhu

Reputation: 1

How to limit memory size in mongo v3.4

In v4.0.12 or later, wiredTigerMaxCacheOverflowSizeGB option is available to specify the maximum size of "lookaside table" file. Is there any parameter which can limit the memory usage in mongo v3.4?

Upvotes: 0

Views: 3335

Answers (2)

D. SM
D. SM

Reputation: 14520

wiredTigerMaxCacheOverflowSizeGB limits disk usage, not memory usage.

For memory usage on 3.4 I use:

--wiredTigerCacheSizeGB 0.25

WiredTiger memory usage: see here

Tell MongoDB how much memory exists in the system: see here

Note that generally, limiting the memory available to the database (such as through system-level configuration) is not useful because if such a limit is reached, the database process will typically immediately terminate. Instead one generally would either:

  • Understand how much memory is required for the workloads being executed, and provision that much memory for the database, or
  • Limit workloads to use the memory which is available (for example through adding indexes or sharding the data).

Upvotes: 1

Joe Drumgoole
Joe Drumgoole

Reputation: 1348

Limiting database memory is a database anti-pattern. The primary goal of a database is to keep your working set in memory. if you really want limit memory consumption run MongoDB inside a container with a memory cap.

Upvotes: 0

Related Questions