MongoDB finishing notes into the world of MongoDB

Source: Internet
Author: User
Tags failover most popular database

I learn MongoDB time is not long, but in view of the needs of the work and the future trend of development, I want to deeper understanding of the underlying principles of MONGODB and more flexible application of mongodb, learning while working practice.

MongoDB belongs to the most popular database in NoSQL, so we might as well have a basic understanding of NoSQL:

NoSQL, full name is "not only Sql", refers to the non-relational database. NoSQL is the most used when the number of key-value storage, of course, there are other document-type, column storage, graph database, XML database and so on. Relational databases impose too many things on you compared to relational databases. They want you to forcibly modify the object data to meet the needs of the database system, rather than the relational data "just give you what you need!"
At present, the more successful cases of large-scale internet companies are Redis, Google's BigTable and Amazon's simpledb of Sina Weibo.
Why Choose NoSQL? Because it adapts to the requirements of the development of the Times.
With the rise of Internet Web 2.0 Web sites, non-relational databases are now an extremely popular new area, non-relational database products are developing very quickly, and traditional relational database in coping with Web 2.0 Web sites, especially ultra-large and high-concurrency SNS type of web 2.0 Pure Dynamic Web site seems to be inadequate, exposing a lot of difficult to overcome problems.
Here are a few questions that are more prominent:

    • High performance database highly concurrent read and write, web2.0 site to the user personalized information to generate dynamic pages in real-time and provide dynamic information, so basically can not use dynamic page static technology, so the database concurrency load is very high, often to achieve tens of thousands of read and write requests per second. Relational databases are barely able to cope with tens of thousands of SQL queries, but with tens of thousands of SQL write data, hard disk IO is intolerable.
    • Huge storage The need for efficient storage and access to massive amounts of data
    • High Scalability&&high availability The need for database scalability and high availability in a web-based architecture where databases are the hardest to scale out, and when the number of users and visits to an application is increasing, Your database has no way to extend performance and load capabilities as simple as Web server and app server by adding more hardware and service nodes. For many websites that need to provide 24-hour uninterrupted service, it is very painful to upgrade and extend the database system, which often requires downtime maintenance and data migration, which is costly.

For web2.0 web site, relational database on this stage can not display its sharp side, a little upsets.

    • Database transaction consistency requirements, many web real-time systems do not require strict database transactions, the requirements for read consistency is very low, and some occasions write consistency requirements are not high. Therefore, database transaction management becomes a heavy burden under the high load of database.
    • Database of realistic time and read real-time requirements, for the relational database, insert a piece of data immediately after the query, is sure to read out this data, but for many web applications, does not require such a high real-time nature.
    • For complex SQL queries, especially multi-table associated query requirements, any large data volume of the Web system, are very taboo of multiple large tables of related queries, as well as complex data analysis types of complex SQL report query, especially the SNS type of Web site, from the requirements and product design perspective, to avoid the emergence of this situation. Often more than just a single table of primary key query, as well as single table simple conditional paging query, SQL function has been greatly weakened.

Let's start with a formal understanding of MongoDB.

MongoDB is a kind of product between relational database and Philippine relational database, and the most abundant function of non-relational data is the most like relational database. The data structure it supports is very loose and is a JSON-like Bson format, so you can store more complex data types. The biggest feature of MongoDB is the support of the query language is very powerful, its syntax is a bit like object-oriented query language, almost can achieve similar relational database single-table query most functions, but also support the indexing of data. It is a collection-oriented, schema-free, document-line database.
Features:

    • Set-oriented (collenction-orented), meaning that data is grouped in a dataset, called a collection (collenction). Each collection has a unique identifying name in the database and can contain an unlimited number of documents. The concept of a collection resembles a relationship
    • Database (RDBMS), the difference is that it does not need to define any schema (schema).
    • Mode Freedom (schema-free) means that for files stored in a MongoDB database, we do not need to know any of its structure definitions.
    • Document type, which means that the data we store is a set of key-value pairs, which are strings, and values can be any type in a collection of data types, including arrays and documents. We call this data format "BSON" i.e. "Binary serialized dOcument Notation."

Features:

    • Collection-oriented storage: data that is suitable for storing objects and JSON forms
    • Dynamic query: MongoDB supports rich query expressions. Query directives use JSON-style markup to easily query objects and arrays embedded in a document
    • Full index support: Includes embedded objects and arrays in the document. The query optimizer of MongoDB parses the query expression and generates an efficient query plan
    • Query monitoring: MongoDB contains a series of monitoring tools for analyzing the performance of database operations
    • Replication and automatic failover: The MongoDB database supports data replication between servers, supports Master-salve mode, and replicates between servers. The primary goal of replication is to provide redundancy and automatic failover
    • Efficient traditional storage: support for binary data and large objects (image)
    • Auto-sharding to support cloud-level scalability: Automatic sharding supports level DB clusters, adding additional machines dynamically

suitable for the scene:

    • Website data: MongoDB is ideal for real-time inserts, updates and queries, as well as the replication and high scalability required for real-time data storage on the site
    • Caching: Because of its high performance, MongoDB is also suitable as a caching layer for the information infrastructure. After a system restart, the persistent cache layer built by MongoDB avoids overloading the underlying data source
    • Large-size, low-value data: Storing some data in a traditional relational database can be expensive, and many times programmers often choose traditional files for storage.
    • Highly scalable scenario: MongoDB is ideal for databases consisting of dozens of or hundreds of servers. MongoDB's roadmap already includes built-in support for the MapReduce engine
    • Storage for objects and JSON data: MongoDB's Bson data format is ideal for storing and querying in document formats

MongoDB finishing notes into the world of MongoDB

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.