Sharded cluster configuration

I have access to 6 servers, let’s name them A, B, C, D, E, F. Can I create 6 shards in my configuration? Let’s say a distrubution like this (for example):

  • Shard 1 - primary A + secondary B, C
  • Shard 2 - primary B + secondary C, D
  • Shard 3 - primary C + secondary D, E
  • Shard 4 - primary D + secondary E, F
  • Shard 5 - primary E + secondary F, A
  • Shard 6 - primary F + secondary A, B

Is it possible and is it a good way to configure my cluster? Or it is completely wrong, because e.g. every node can be used only once. Or maybe configuration like that has no sense and it is better to just go for 2 shards ABC and DEF? If so, adding new shard always means I need to get 3 more servers?

You are missing 2 critical components for sharding.

1 - config servers
2 - mongos

yes, of course, I forgot to mention it, for now those were put on one of data nodes, but we are in the process of moving them to separate nodes. I’m mostly curious of data nodes, where mongod needs to be places

Hi there,
I recommend only running one mongod process per node, as there could be memory contention with multiple WiredTiger caches on the same machine. If this is for testing rather than a production system, then yes it’s possible. How much data are you storing for retrieval that you require distribution to six shards?

1 Like

@Zynon_Putney1 thanks for answering. It is a microservices based system. For now everything works fine, but with more load ahead I’ve started to do some performance testing and it is not looking that good. I thought more shards equals better data distribution and quicker responses. That’s why I’m asking

Depending on the type of workload, you could use a standard 3 node replica set, with the additional 3 nodes for workload isolation, setting them as read-only non voting nodes. This would give you additional read capacity. If the write performance is lacking, then this would not address that issue. Sharding is typically reserved for very large datasets (for example: larger than 4TB).

@Zynon_Putney1 I wasn’t thinking about multiple mongod on one server, but about one mongod being a primary for one shard and a secondary for some other shard(s)

The secondaries are also mongod and from you describe you are running 3 mongod per node.

The main issue is that secondaries handle the exact same write traffic as the primaries.