replicaset vs multi-mongos vs multiple connections

mongodb, mongoose, node.js

Solution

Replica-Set

A replica-set are two or more MongoDB servers which mirror the same data. Reads can be served by any member of the set, but writes can only be handled by a single server (the "Master" or "Primary").

An application can only connect to the replica-set members it knows, so you need to tell it the hostnames and ports of all of them. There are cases where you want to restrict an application to specific members. In that case you wouldn't tell them about the other servers.

Multiple `mongos`

Another feature to scale MongoDB on multiple servers is sharding. A sharded cluster consists of multiple replica-sets or stand-alone MongoDB servers where each one has only a part of the data. This improves both read- and write performance but is technically more complex. When an application wants to connect to a cluster, it doesn't connect to the MongoDB processes directly. Each connection goes through a MongoDB router instead (`mongos`) which forwards each query to the `mongod`'s who are responsible for it. For increased performance and redundancy, a cluster can have multiple `mongos` servers. When this is the case, the clients should pick one at random for each connection.

Multiple connections

When your application opens multiple connections to the database, it can perform multiple requests in parallel. Usually the database driver should do this automatically, so you don't have to worry about this, unless you need to connect to multiple databases at the same time or you need connections with different connection settings for some reason.

Problem

what is the difference and why use each of this features of mongoose? for now I just need a method to transfer a document from one database to another.

Original source