Part V Architecture Chapter 19th MongoDB sharding Architecture (MONGOs)

Source: Internet
Author: User
Tags mongodb sharding

1, MONGOs

MONGOs is a point of interaction between the user and the cluster, whose duty is to hide the complexity inside the Shard and provide the user with a simple single-server interface, and there are gaps in the abstraction layer, but in most cases mongos allows you to use a cluster as a server.

When using a cluster, you should connect to a mongos and send it all read and write operations, but you should not access the shards directly (if you want to).

MONGOs will forward all user requests to the appropriate shard, and if the user inserts a document, MONGOs will view the document's slice key, control the data block, and send the document to the Shard holding the corresponding block.

For example, if we want to insert {"foo": "Bar"} and have made a shard with Foo as the chip key, MONGOs will look at all the available blocks and then discover that a block of {"A": "C"} should contain bar, which is on Shard 2, So MONGOs sends the insert message to Shard 2.


Description

If a query involves a slice key, MONGOs can use and insert the same process and find some (or some) of the correct shards and send them a query, called a targeted query (targeted), because it only targets shards that might contain the data we're looking for. If it knows we're looking for {"foo": "Bar"}, then it doesn't make sense to query the Shard with the slice key value greater than bar.

If the query does not contain a slice key, MONGOs must send the query to all shards, which may be less efficient than the true query, but not necessarily, if a broad query accesses only a small number of documents in memory that have been indexed, and a targeted query has to access the disk data distributed across multiple shards, comparing the two The performance of the former is certainly much higher than the latter.


2. Configure the server

The MONGOs process does not persist any data, and the cluster configuration is stored on a dedicated set of Mongod, known as configuration servers (config server), and the configuration server contains the most complete and reliable information about the cluster for everyone (sharding, MONGOs process, and system administrator Access

To ensure that the data block is migrated successfully, all configuration servers must be in the same order, and if any of them is down, all the migrations that are currently in progress will be rolled back and stopped until the entire configuration server is running, and any one configuration server is down and the cluster configuration cannot be changed.


3, the structure of the cluster

A MongoDB cluster is basically composed of 3 types of processes, that is, the shards that actually store the data, the MONGOs process that is responsible for routing the request to the correct data, and the configuration server for tracking the state of the cluster


3 Components of a cluster

Description

Each component in a cluster can contain multiple processes, as shown in the following:


Each component can contain multiple processes

Description

Each of these components is not a machine, the MONGOs process usually runs on the application server (AppServer), configures the server, because of its importance, is very lightweight and can basically run on any machine, each shard is usually composed of multiple machines, because they actually store the data.

Part V Architecture Chapter 19th MongoDB sharding Architecture (MONGOs)

Related Article

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.