murvinlai
murvinlai

Reputation: 50355

Can I shard Mongo base on IP address?

Instead of sharding base on the data, can I shard based on where the request (IP address) coming from?

Hmmm one trick I think of is the data itself contains IP address. Is there another way?

Upvotes: 3

Views: 474

Answers (1)

Chris Fulstow
Chris Fulstow

Reputation: 41882

Yes, you'd need to include an IP address field in each document and include it in your shard key. Choosing a good shard key is quite a tricky thing to get right, it depends a lot on the shape of your data and how it'll be queried.

Here's a good place to start: Choosing a Mongo Shard Key

Upvotes: 3

Related Questions