I'm trying to define the architecture for a production sharded mongoDB server, I see in the documentation that each shard has to contain 3 replica-sets. I would like to have the sharding advantages(being able to compute distributed queries in the nodes depending on the shard key) and the replication failover functionality, but reducing the budget (and the number of servers).
The idea is to use small machines of 7GB RAM and 2 core 2GHz:
I have been searching and I found some people was installing the different replicas of the shards sharing nodes in the following schema:
Server 1: shard1, rep-shard2, arbitrer3 Server 2: shard2, rep-shard1, arbitrer2 Server 3: shard3, rep-shard2, arbitrer1
I tried this using docker and it works, however I don't know if I can have any performance issues by sharing the same node as the replica-set and the shard.
Another option is to use 4 cluster and 2 shards with the following schema which I don't like that much (1 more node, 1 less shard) but maybe would be could be better in terms of performance.
Server1: shard1, Server2: rep-shard1 arbitrer2 Server3: shard2, Server4: rep-shard2 arbitrer1