@@ -163,6 +163,8 @@ files can simply be released from memory without going to swap or can be
163
163
written back to the database files without needing to be swapped out to
164
164
disk, as they are already backed by files.
165
165
166
+ .. _faq-fundamentals-working-set:
167
+
166
168
Must my working set size fit RAM?
167
169
---------------------------------
168
170
@@ -181,6 +183,8 @@ index pages will be much smaller.
181
183
182
184
It is fine if databases and thus virtual size are much larger than RAM.
183
185
186
+ .. _faq-fundamentals-working-set-size:
187
+
184
188
How can I measure working set size?
185
189
-----------------------------------
186
190
@@ -204,11 +208,49 @@ too low. If disk I/O activity increases significantly, terminate
204
208
eatmem.cpp to mitigate the problem for the moment until further steps
205
209
can be taken.
206
210
207
- In :term:`replica sets <repica set>`, if one server is underpowered the
211
+ In :term:`replica sets <replica set>`, if one server is underpowered the
208
212
eatmem.cpp utility could help as an early warning mechanism for server
209
213
capacity. Of course, the server must be receiving representative traffic
210
214
to get an indication.
211
215
216
+ How do I calculate how much RAM I need for my application?
217
+ ----------------------------------------------------------
218
+
219
+ .. todo Improve this FAQ
220
+
221
+ The amount of RAM you need depends on several factors, including but not
222
+ limited to:
223
+
224
+ - The relationship between :ref:`database storage </faq/storage>` and working set.
225
+
226
+ - The operating system's cache strategy for LRU (Least Recently Used)
227
+
228
+ - The impact of :doc:`journaling </administration/journaling>`
229
+
230
+ - Using page faults and other MMS gauges to detect when you need more RAM
231
+
232
+ MongoDB makes no choices regarding what data is loaded into memory from
233
+ disk. It simply :ref:`memory maps <faq-storage-memory-mapped-files>` all
234
+ its data files and relies on the operating system to cache data. The OS
235
+ typically evicts the least-recently-used data from RAM when it runs low
236
+ on memory. For example if indexes are accessed more frequently then
237
+ documents then indexes will more likely stay in RAM, but it depends on
238
+ your particular usage.
239
+
240
+ To calculate how much RAM you need, you must calculate your working set
241
+ size, i.e., the portion of your data that is frequently accessed. This
242
+ depends on your access patterns, what indexes you have, and the size of
243
+ your documents. To calculate working set size, see:
244
+
245
+ - :ref:`faq-fundamentals-working-set`
246
+
247
+ - :ref:`faq-fundamentals-working-set-size`
248
+
249
+ If page faults are low (for example, below than 100 / sec), then your
250
+ working set fits in RAM. If fault rates rise higher than that, you risk
251
+ performance degradation. This is less critical with SSD drives than
252
+ spinning disks.
253
+
212
254
How do I read memory statistics in the UNIX ``top`` command
213
255
-----------------------------------------------------------
214
256
@@ -230,19 +272,6 @@ MongoDB has no configurable cache. MongoDB uses all *free* memory on
230
272
the system automatically by way of memory-mapped files. Operating
231
273
systems use the same approach with their file system caches.
232
274
233
- Are writes written to disk immediately, or lazily?
234
- --------------------------------------------------
235
-
236
- Writes are physically written to the journal within 100
237
- milliseconds. At that point, the write is "durable" in the sense that
238
- after a pull-plug-from-wall event, the data will still be recoverable after
239
- a hard restart.
240
-
241
- While the journal commit is nearly instant, MongoDB writes to the data
242
- files lazily. MongoDB may wait to write data to the data files for as
243
- much as one minute. This does not affect durability, as the journal
244
- has enough information to ensure crash recovery.
245
-
246
275
.. _faq-database-and-caching:
247
276
248
277
Does MongoDB require a separate caching layer for application-level caching?
@@ -262,21 +291,6 @@ data to application objects require joins, this process increases the
262
291
overhead related to using the database which increases the importance
263
292
of the caching layer.
264
293
265
- How do I calculate how much RAM I need for my application?
266
- ----------------------------------------------------------
267
-
268
- The amount of RAM you need depends on several factors:
269
-
270
- - The relationship between database storage and working set
271
-
272
- - The operating system's cache strategy for LRU (Least Recently Used)
273
-
274
- - The impact of journaling
275
-
276
- - Using page faults and other MMS gauges to detect when you need more RAM
277
-
278
- .. todo This topic is a work in progress
279
-
280
294
Does MongoDB handle caching?
281
295
----------------------------
282
296
@@ -287,6 +301,19 @@ in RAM, MongoDB serves all queries from memory.
287
301
MongoDB does not implement a query cache: MongoDB serves all queries
288
302
directly from the indexes and/or data files.
289
303
304
+ Are writes written to disk immediately, or lazily?
305
+ --------------------------------------------------
306
+
307
+ Writes are physically written to the journal within 100
308
+ milliseconds. At that point, the write is "durable" in the sense that
309
+ after a pull-plug-from-wall event, the data will still be recoverable after
310
+ a hard restart.
311
+
312
+ While the journal commit is nearly instant, MongoDB writes to the data
313
+ files lazily. MongoDB may wait to write data to the data files for as
314
+ much as one minute. This does not affect durability, as the journal
315
+ has enough information to ensure crash recovery.
316
+
290
317
What language is MongoDB written in?
291
318
------------------------------------
292
319
0 commit comments