I have undertaken a project for hotel reservation system. A want to use mongo as my db and as I am a biggener I have a simple question.
The idea is that we will have multiple servers for mongo where each server will contain hotels for a specific country. So lets say for example that our application launches in 4 countries UK, France, Italy and Spain.
In our mongodb we will have 4 servers, where each server will contain hotels for the specific country such as:
Server 1: UK
Server 2: France
Server 3: Italy
Server 4: Spain
This is what I am thinking to to. Does this sound like a good practice to you?
If yes how can I accomplish this? My application is build with spring and I am talking to mongo through spring data.
Thanks in advance,
I am guessing that i will sharding. My question is should I use as sharding key the country code, so that all queries for specific country go to one machine or you would recommend sharding with id so that queries split up?
It really depends on how balanced the data is (eg will each of those countries have more or less the same number of hotels), how write heavy it is, etc. If all you care about is for instance have your web servers in france have to take less hops to get data then you could use tag aware sharding: http://docs.mongodb. org/manual/core/tag-aware- sharding/.
In the grand scheme of things I would *think* the latency between those countries would be fairly small though of course network partitions can happen.
The basic idea with shard keys is to not use a monotonically increasing primary key because that creates hotspots where all your newest data goes on one machine. Instead you want to use a hashed key.
This has a good broad overview of some of these topics:
댓글 없음:
댓글 쓰기