Skip to content

Commit e54bc21

Browse files
author
Bob Grabar
committed
DOCS-491 first draft
1 parent 5cdac48 commit e54bc21

File tree

1 file changed

+56
-29
lines changed

1 file changed

+56
-29
lines changed

source/faq/fundamentals.txt

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ files can simply be released from memory without going to swap or can be
163163
written back to the database files without needing to be swapped out to
164164
disk, as they are already backed by files.
165165

166+
.. _faq-fundamentals-working-set:
167+
166168
Must my working set size fit RAM?
167169
---------------------------------
168170

@@ -181,6 +183,8 @@ index pages will be much smaller.
181183

182184
It is fine if databases and thus virtual size are much larger than RAM.
183185

186+
.. _faq-fundamentals-working-set-size:
187+
184188
How can I measure working set size?
185189
-----------------------------------
186190

@@ -204,11 +208,49 @@ too low. If disk I/O activity increases significantly, terminate
204208
eatmem.cpp to mitigate the problem for the moment until further steps
205209
can be taken.
206210

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
208212
eatmem.cpp utility could help as an early warning mechanism for server
209213
capacity. Of course, the server must be receiving representative traffic
210214
to get an indication.
211215

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+
212254
How do I read memory statistics in the UNIX ``top`` command
213255
-----------------------------------------------------------
214256

@@ -230,19 +272,6 @@ MongoDB has no configurable cache. MongoDB uses all *free* memory on
230272
the system automatically by way of memory-mapped files. Operating
231273
systems use the same approach with their file system caches.
232274

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-
246275
.. _faq-database-and-caching:
247276

248277
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
262291
overhead related to using the database which increases the importance
263292
of the caching layer.
264293

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-
280294
Does MongoDB handle caching?
281295
----------------------------
282296

@@ -287,6 +301,19 @@ in RAM, MongoDB serves all queries from memory.
287301
MongoDB does not implement a query cache: MongoDB serves all queries
288302
directly from the indexes and/or data files.
289303

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+
290317
What language is MongoDB written in?
291318
------------------------------------
292319

0 commit comments

Comments
 (0)