Skip to content

Commit f5c069b

Browse files
committed
DOCS-4667 faq-storage
1 parent 9a86bdc commit f5c069b

File tree

6 files changed

+141
-95
lines changed

6 files changed

+141
-95
lines changed

source/core/index-text.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ Storage Requirements and Performance Costs
127127
``text`` indexes have the following storage requirements and
128128
performance costs:
129129

130-
- ``text`` indexes change the space allocation method for all future
131-
record allocations in a collection to :collflag:`usePowerOf2Sizes`.
132-
133130
- ``text`` indexes can be large. They contain one index entry for each
134131
unique post-stemmed word in each indexed field for each document
135132
inserted.

source/faq/fundamentals.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,18 @@ performance.
139139
.. seealso:: :doc:`/faq/diagnostics` for answers to additional
140140
questions about MongoDB and Memory use.
141141

142-
How do I configure the cache size?
143-
----------------------------------
144-
145-
MongoDB has no configurable cache. MongoDB uses all *free* memory on
146-
the system automatically by way of memory-mapped files. Operating
147-
systems use the same approach with their file system caches.
142+
How do I configure the cache size for MMAPv1?
143+
---------------------------------------------
144+
145+
MongoDB has no configurable cache for MMAPv1 storage engine. MongoDB
146+
uses all *free* memory on the system automatically by way of
147+
memory-mapped files. Operating systems use the same approach with their
148+
file system caches.
149+
150+
For the WiredTiger storage engine, you can specify the maximum size of
151+
the cache that WiredTiger will use for all data. See
152+
:setting:`storage.wiredTiger.engineConfig.cacheSizeGB` and
153+
:option:`--wiredTigerCacheSizeGB`.
148154

149155
.. _faq-database-and-caching:
150156

source/faq/storage.txt

Lines changed: 122 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ What will be the default storage engine going forward?
2828
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2929

3030
MMAPv1 is the default storage engine in 3.0. With multiple storage
31-
engines, you will always be able to decide which storage engine is
31+
engines, you can decide which storage engine is
3232
best for your application.
3333

3434
Can you mix storage engines in a replica set?
@@ -47,14 +47,14 @@ following:
4747
captures data files from MongoDB: you may need to maintain backups
4848
for each storage engine.
4949

50-
Wired Tiger Storage Engine
51-
--------------------------
50+
WiredTiger Storage Engine
51+
-------------------------
5252

5353
Can I upgrade an existing deployment to a WiredTiger?
5454
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5555

5656
Yes. You can upgrade an existing deployment to WiredTiger while the
57-
deployment remains continuously available by adding replica set
57+
deployment remains available by adding replica set
5858
members with the new storage engine and then removing members with the
5959
legacy storage engine. See the following sections of the
6060
:doc:`/release-notes/3.0-upgrade` for the complete procedure that you
@@ -68,13 +68,72 @@ How much compression does WiredTiger provide?
6868
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6969

7070
The ratio of compressed data to uncompressed data depends on your data
71-
and the compression library used. Collection data in WiredTiger use
72-
Snappy :term:`block compression` by default, although ``zlib``
73-
compression is also optionally available. Index data use
74-
:term:`prefix compression` by default.
71+
and the compression library used. By default, collection data in
72+
WiredTiger use :term:`Snappy block compression <snappy>`; :term:`zlib`
73+
compression is also available. Index data use :term:`prefix
74+
compression` by default.
7575

76-
MMAP Storage Engine
77-
-------------------
76+
.. _wt-cache-and-eviction:
77+
78+
To what size should I set the WiredTiger cache?
79+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80+
81+
The size of the cache should be sufficient to hold the entire working
82+
set for the :program:`mongod`. If the cache does not have enough space
83+
to load additional data, WiredTiger evicts pages from the cache to free
84+
up space.
85+
86+
To see statistics on the cache and eviction, use the
87+
:dbcommand:`serverStatus` command. The
88+
:data:`~serverStatus.wiredTiger.cache` field holds the information on
89+
the cache and eviction:
90+
91+
.. code-block:: none
92+
93+
...
94+
"wiredTiger" : {
95+
...
96+
"cache" : {
97+
"tracked dirty bytes in the cache" : <num>,
98+
"bytes currently in the cache" : <num>,
99+
"maximum bytes configured" : <num>,
100+
"bytes read into cache" :<num>,
101+
"bytes written from cache" : <num>,
102+
"pages evicted by application threads" : <num>,
103+
"checkpoint blocked page eviction" : <num>,
104+
"unmodified pages evicted" : <num>,
105+
"page split during eviction deepened the tree" : <num>,
106+
"modified pages evicted" : <num>,
107+
"pages selected for eviction unable to be evicted" : <num>,
108+
"pages evicted because they exceeded the in-memory maximum" : <num>,,
109+
"pages evicted because they had chains of deleted items" : <num>,
110+
"failed eviction of pages that exceeded the in-memory maximum" : <num>,
111+
"hazard pointer blocked page eviction" : <num>,
112+
"internal pages evicted" : <num>,
113+
"maximum page size at eviction" : <num>,
114+
"eviction server candidate queue empty when topping up" : <num>,
115+
"eviction server candidate queue not empty when topping up" : <num>,
116+
"eviction server evicting pages" : <num>,
117+
"eviction server populating queue, but not evicting pages" : <num>,
118+
"eviction server unable to reach eviction goal" : <num>,
119+
"pages split during eviction" : <num>,
120+
"pages walked for eviction" : <num>,
121+
"eviction worker thread evicting pages" : <num>,
122+
"in-memory page splits" : <num>,
123+
"percentage overhead" : <num>,
124+
"tracked dirty pages in the cache" : <num>,
125+
"pages currently held in the cache" : <num>,
126+
"pages read into cache" : <num>,
127+
"pages written from cache" : <num>,
128+
},
129+
...
130+
131+
To adjust the size of the WiredTiger cache, see
132+
:setting:`storage.wiredTiger.engineConfig.cacheSizeGB` and
133+
:option:`--wiredTigerCacheSizeGB`.
134+
135+
MMAPv1 Storage Engine
136+
---------------------
78137

79138
.. _faq-storage-memory-mapped-files:
80139

@@ -84,25 +143,23 @@ What are memory mapped files?
84143
A memory-mapped file is a file with data that the operating system
85144
places in memory by way of the ``mmap()`` system call. ``mmap()`` thus
86145
*maps* the file to a region of virtual memory. Memory-mapped files are
87-
the critical piece of the storage engine in MongoDB. By using memory
88-
mapped files MongoDB can treat the contents of its data files as if
146+
the critical piece of the MMAPv1 storage engine in MongoDB. By using memory
147+
mapped files, MongoDB can treat the contents of its data files as if
89148
they were in memory. This provides MongoDB with an extremely fast and
90149
simple method for accessing and manipulating data.
91150

92151
How do memory mapped files work?
93152
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94153

95-
Memory mapping assigns files to a block of virtual memory with a
96-
direct byte-for-byte correlation. Once mapped, the relationship
97-
between file and memory allows MongoDB to interact with the data in
98-
the file as if it were memory.
154+
MongoDB uses memory mapped files for managing and interacting with all
155+
data.
99156

100-
How does MongoDB work with memory mapped files?
101-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
157+
Memory mapping assigns files to a block of virtual memory with a direct
158+
byte-for-byte correlation. MongoDB memory maps data files to memory as
159+
it accesses documents. Unaccessed data is *not* mapped to memory.
102160

103-
MongoDB uses memory mapped files for managing and interacting with all
104-
data. MongoDB memory maps data files to memory as it accesses
105-
documents. Data that isn't accessed is *not* mapped to memory.
161+
Once mapped, the relationship between file and memory allows MongoDB to
162+
interact with the data in the file as if it were memory.
106163

107164
.. _faq-disk-size:
108165

@@ -171,38 +228,6 @@ inserted into the database. Consider the following possible causes:
171228
running. Be aware that :dbcommand:`repairDatabase` will block
172229
all other operations and may take a long time to complete.
173230

174-
How do I know when the server runs out of disk space?
175-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
176-
177-
If your server runs out of disk space for data files, you will see
178-
something like this in the log:
179-
180-
.. code-block:: none
181-
182-
Thu Aug 11 13:06:09 [FileAllocator] allocating new data file dbms/test.13, filling with zeroes...
183-
Thu Aug 11 13:06:09 [FileAllocator] error failed to allocate new file: dbms/test.13 size: 2146435072 errno:28 No space left on device
184-
Thu Aug 11 13:06:09 [FileAllocator] will try again in 10 seconds
185-
Thu Aug 11 13:06:19 [FileAllocator] allocating new data file dbms/test.13, filling with zeroes...
186-
Thu Aug 11 13:06:19 [FileAllocator] error failed to allocate new file: dbms/test.13 size: 2146435072 errno:28 No space left on device
187-
Thu Aug 11 13:06:19 [FileAllocator] will try again in 10 seconds
188-
189-
The server remains in this state forever, blocking all writes
190-
including deletes. However, reads still work. With MMAPv1 you can
191-
delete some data and compact, using the :dbcommand:`compact` command;
192-
however, you must restart the server first.
193-
194-
If your server runs out of disk space for journal files, the server
195-
process will exit. By default, :program:`mongod` creates journal files
196-
in a sub-directory of :setting:`~storage.dbPath` named ``journal``. You may
197-
elect to put the journal files on another storage device using a
198-
filesystem mount or a symlink.
199-
200-
.. note::
201-
202-
If you place the journal files on a separate storage device you
203-
will not be able to use a file system snapshot tool to capture a
204-
valid snapshot of your data files and journal files.
205-
206231
.. _faq-working-set:
207232

208233
What is the working set?
@@ -253,59 +278,74 @@ storage engine, needs access to data that isn't currently in active
253278
memory. A "hard" page fault refers to situations when MongoDB must
254279
access a disk to access the data. A "soft" page fault, by contrast,
255280
merely moves memory pages from one list to another, such as from an
256-
operating system file cache. In production, MongoDB will rarely
257-
encounter soft page faults.
281+
operating system file cache.
258282

259283
See :ref:`administration-monitoring-page-faults` for more information.
260284

261285
Data Storage Diagnostics
262286
------------------------
263287

264-
How can I check the size of indexes?
265-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
266-
267-
To view the size of the data allocated for an index, use one of the
268-
following procedures in the :program:`mongo` shell:
269-
270-
Check the value of :data:`~collStats.indexSizes` in the output of the
271-
:method:`db.collection.stats()` method.
272-
273288
How can I check the size of a collection?
274289
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
275290

276-
To view the size of a collection and other information, use the
277-
:method:`db.collection.stats()` method from the :program:`mongo` shell.
278-
The following example issues :method:`db.collection.stats()` for the
279-
``orders`` collection:
291+
To view the statistics for a collection, including the data size, use
292+
the :method:`db.collection.stats()` method from the :program:`mongo`
293+
shell. The following example issues :method:`db.collection.stats()` for
294+
the ``orders`` collection:
280295

281296
.. code-block:: javascript
282297

283298
db.orders.stats();
284299

285-
To view specific measures of size, use these methods:
300+
MongoDB also provides the following methods to return specific sizes
301+
for the collection:
286302

287-
- :method:`db.collection.dataSize()`: data size in bytes for the collection.
288-
- :method:`db.collection.storageSize()`: allocation size in bytes, including unused space.
289-
- :method:`db.collection.totalSize()`: the data size plus the index size in bytes.
290-
- :method:`db.collection.totalIndexSize()`: the index size in bytes.
303+
- :method:`db.collection.dataSize()` to return data size in bytes for
304+
the collection.
291305

292-
Also, the following scripts print the statistics for each database and
293-
collection:
306+
- :method:`db.collection.storageSize()` to return allocation size in
307+
bytes, including unused space.
308+
309+
- :method:`db.collection.totalSize()` to return the data size plus the
310+
index size in bytes.
311+
312+
- :method:`db.collection.totalIndexSize()` to return the index size in
313+
bytes.
314+
315+
The following script prints the statistics for each database:
294316

295317
.. code-block:: javascript
296318

297-
db._adminCommand("listDatabases").databases.forEach(function (d) {mdb = db.getSiblingDB(d.name); printjson(mdb.stats())})
319+
db._adminCommand("listDatabases").databases.forEach(function (d) {
320+
mdb = db.getSiblingDB(d.name);
321+
printjson(mdb.stats());
322+
})
323+
324+
The following script prints the statistics for each collection in each
325+
database:
298326

299327
.. code-block:: javascript
300328

301-
db._adminCommand("listDatabases").databases.forEach(function (d) {mdb = db.getSiblingDB(d.name); mdb.getCollectionNames().forEach(function(c) {s = mdb[c].stats(); printjson(s)})})
329+
db._adminCommand("listDatabases").databases.forEach(function (d) {
330+
mdb = db.getSiblingDB(d.name);
331+
mdb.getCollectionNames().forEach(function(c) {
332+
s = mdb[c].stats();
333+
printjson(s);
334+
})
335+
})
336+
337+
How can I check the size of indexes for a collection?
338+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
339+
340+
To view the size of the data allocated for an index, use the
341+
:method:`db.collection.stats()` method and check the
342+
:data:`~collStats.indexSizes` field in the returned document.
302343

303344
.. _faq-tools-for-measuring-storage-use:
304345

305-
What tools can I use to investigate storage use in MongoDB?
346+
How can I get information on the storage use of a database?
306347
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
307348

308-
The :method:`db.stats()` method in the :program:`mongo` shell
309-
returns the current state of the "active" database. The
310-
:dbcommand:`dbStats` document describes
311-
the fields in the :method:`db.stats()` output.
349+
The :method:`db.stats()` method in the :program:`mongo` shell returns
350+
the current state of the "active" database. For the description of the
351+
returned fields, see :ref:`dbStats Output <dbstats-output>`.

source/reference/command/dbStats.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Definition
3737
In the :program:`mongo` shell, the :method:`db.stats()` function
3838
provides a wrapper around :dbcommand:`dbStats`.
3939

40+
.. _dbstats-output:
41+
4042
Output
4143
------
4244

source/reference/command/setParameter.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@ setParameter
5252
- :parameter:`journalCommitInterval`
5353
- :parameter:`syncdelay`
5454
- :parameter:`wiredTigerEngineRuntimeConfigSetting`
55+
5556
.. slave-ok, admin-only
5657
.. textSearchEnabled, deprecated v2.6

source/reference/glossary.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ Glossary
754754
:term:`CRUD` operations that apply to them. Typically REST is
755755
implemented over HTTP. MongoDB provides a simple HTTP REST
756756
interface that allows HTTP clients to run commands against the
757-
server. See :ref:`rest-interface` and :ref:`rest-api`.
757+
server. See :ref:`rest-api`.
758758

759759
role
760760
A set of privileges that permit :term:`actions <action>` on
@@ -827,8 +827,8 @@ Glossary
827827
A compression/decompression library designed to balance
828828
efficient computation requirements with reasonable compression rates.
829829
Snappy is the default compression
830-
library for MongoDB's use of ':ref:`WiredTiger
831-
<storage-wiredtiger>`. See: `Snappy
830+
library for MongoDB's use of :ref:`WiredTiger
831+
<storage-wiredtiger>`. See `Snappy
832832
<https://code.google.com/p/snappy/>`_ and the `WiredTiger compression
833833
documentation <http://source.wiredtiger.com/2.4.1/compression.html>`_
834834
for more information.
@@ -982,7 +982,7 @@ Glossary
982982
A data compression library that provides higher compression rates
983983
at the cost of more CPU, compared to MongoDB's use of
984984
:term:`snappy`. You can configure :ref:`WiredTiger
985-
<storage-wiredtiger>` to use zlib as its compression library. See:
985+
<storage-wiredtiger>` to use zlib as its compression library. See
986986
http://www.zlib.net and the `WiredTiger compression documentation
987987
<http://source.wiredtiger.com/2.4.1/compression.html>`_ for more
988988
information.

0 commit comments

Comments
 (0)