MONGO Sub-Library scheme selection

Source: Internet
Author: User

Two forms of MONGO are analyzed:

1. Mongo sharding Way: 1.1. Problems with deep ploughing pagesExample: When the MONGO Shard is 5, paging query (if the creation time flashbacks query) the first page, 50 data per page, then MONGO sharding 50 data on each shard, a total of 505 data, and then summarized, calculated the first 50 correct data as the return result. If you are paging to page 1000, then MONGO sharding need to query 501000 = 50,000 bar data from 5 shards, then summarize it to 5010005 = 250,000 data, then calculate the data on page 1000th, so that the system consumes a lot of system resources. can easily cause system anomalies. There is no solution to this problem for the time being.
1.2. MONGO Sharding re-balancing, it is possible to query data duplication problemWhen the MONGO sharding according to Sharding Key, the data into the MONGO 5 slices (1,2,3,4,5), the general will produce 5 shards of data is uneven, if the data of the Shard is more, 3,4,5 the amount of fragmented data is less, then MONGO The sharding rebalancing strategy balances the data on the 1, 2 shards onto the 3,4,5 shard, and if the data is being balanced at this point, it is possible to duplicate data when querying the data on the Shard to balance the data in the 3,4,5 part, and without hitting the index. The existing solution is to balance the data at a time when the number of calls is low at night, and to close the data balance when the traffic is large during the day.
1.3. MONGO Shard extensionFragmentation can not be infinitely expanded, the actual use of the general divided into single-digit shards, it is difficult to achieve unlimited expansion.
1.4. Sharding key cannot be changedSharding key cannot be changed once it is specified. After the change, the Shard logic that accesses the data changes, causing the service to become unavailable.

2. Adopt Physical Library Method: 2.1 Library to implement your own codeYou need to implement your own code to access different databases according to different context, that is, the implementation is routed to a different physical library based on the key of the library.
2.2 Different sub-library cross-access issuesIt is not possible to cross-access the library directly like MONGO sharding, if you want to cross-access the library, you can only do it yourself in the program.
2.3 Load BalancingMONGO sharding Internal load balancing, if the use of physical partitioning into multiple MONGO libraries, to achieve load balancing needs their own code implementation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.