Compact an Atlas Volume
Overview
While Realm data compaction defragments the storage
space the realm file uses on a client, and also reduces the size of the
__realm_sync
database on Atlas clusters, it does not reduce the overall size of
the Atlas cluster. Compacting the data on an Atlas volume involves several
additional steps.
Steps to Compact and Reclaim Disk Space
You should use the following guidance for reducing Atlas disk space usage:
Enable Compaction in App Services
Before reclaiming volume space, be sure that you have enabled Compaction on your Atlas App Services app. You set this by setting the Max Offline Time setting in the Atlas UI. For more information, see Optimize Sync Storage in Atlas.
Note
Wait for Compaction
If you are enabling compaction for the first time, you will need to wait for the compaction to happen before continuing. You can file a ticket with support if you want to ensure compaction has completed.
Perform a Rolling Resync
Perform a rolling resync of your Atlas cluster, a process explained in Resync a Member of a Replica Set.
The commands to do this are not available with Atlas. Instead, you can file a ticket with support to have this process done for you.
An Alternate Approach
A final approach you can take for reclaiming some of your Atlas volume space
is to run the compact()
command. You run it on one of the secondary nodes
and then the other secondary node(s). Finally, you perform a failover on the
primary mode and then run compact()
. For more information on this approach,
support-enabled customers can refer to How to use the compact() command in
Atlas. Contact
Support for access.
Note
The compact()
command may not reduce the volume size as much as
performing a rolling resync.