Mongodb – Amount of Data transferred out in mongorestore

mongodbmongorestore

I'm using MongoDB version 4

Consider I have a database with dataSize 15GB, storageSize 10GB.
After I mongodump --gzip it, the file created is of 5GB.

Now, If I'm restoring it to a remote machine (M2), using mongorestore on my workstation (M1), will the data transferred out of M1 be around 5GB or 10GB or 15GB?

Best Answer

MongoDB 3.4 and newer servers can negotiate network compression if MongoDB clients/drivers have also been updated to support the compressed message format. Network compression was introduced as an optional feature in MongoDB 3.4 and is enabled by default for MongoDB 3.6+ servers.

Unfortunately the mgo driver used by mongodump (as at MongoDB 4.0) does not support network compression and is no longer actively maintained. The expected outcome is that mongorestore or mongodump data transfer will roughly match your dataSize (plus some network overhead).

An officially supported MongoDB Go driver is currently in development and will include full support for the latest MongoDB features. Once the new Go driver is ready, the server command line tools will be updated to be able to take advantage of additional options. A relevant issue to upvote/watch in the MongoDB issue tracker is TOOLS-1668 (Support wire protocol compression in mongodump and mongorestore).

In the interim there are a few possible workarounds if network compression will significantly improve your transfer time to a remote server:

  • Copy the gzipped mongodump file to your remote server and restore locally
  • Use an SSH or VPN connection which supports network compression