Quantcast
Channel: StackExchange Replication Questions
Viewing all articles
Browse latest Browse all 17268

Best design of mongo replica set for DB read/write speed

$
0
0

I'm building a Node app that uses MongoDB. Whilst it would probably be fine to have node and mongo sitting on the same VPS, I want to ensure that the MongoDB is backed up and maintain high availability in the case the VPS goes offline.

Looking in to the options available to me, one stood out: creating a replica set.

I have a couple of questions about how best to design the replica set to ensure the maximum speed of my app (as it does a lot of DB read/write):

  1. Surely running mongo on a remote server will slow things down considerably? Instead of performing read/write requests on the same disk, each DB operation has to be sent across datacenters to the remote server. For example, say the ping time between the two servers was 100ms, then making 10 requests would slow down the app by almost 1 second!

  2. With that in mind, would the following setup work?:

    • Server 1: Node + MongoDB (primary member of replica set)
    • Server 2: MongoDB secondary member - located in a separate datacenter ideally close to Server 1
    • Server 3: MongoDB secondary member - located in a separate datacenter ideally close to Server 1

That way, whilst everything is working normally, I benefit from the speed of executing DB commands on the same server as the node app; and when things go wrong, I still have redundancy.


Viewing all articles
Browse latest Browse all 17268

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>