ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • MongoDB
    DB/Nosql 2019. 9. 20. 10:11

    1. Overview

    MongoDB is a cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with schema. MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License (SSPL)

     

    2. Description

    2.1 Ad hoc queries

    MongoDB supports field, range query, and regular expression searches. Queries can return specific fields of documents and also include user-defined Javascript functions. Queries can also be configured to return a random sample of results of a given size.

    2.2 Indexing

    Fields in a MongoDB document can be indexed with primary and secondary indices.

    2.3 Replication

    2.3.1 Consistency

    In MongoDB, the scenario for a single database consists of two observers P and Q, and there documents with a value x equal to 123. At some point, P decides to update that document, by assigning 789 to x. And during the update, Q’s observation can either be the record just before P made the update, the meaning 123, or just after if it waited for the lock to be released.

    These are termed as eventual consistency. And eventually, this document will make it over to the secondary database. And can choose the consistency and durability of a model that supports the MongoDB database and the difference between durability and consistency in the context of eventual consistency.

    Durability is about whether the data was persisted to durable media before control was returned. Eventual consistency in a replica set has a document that is composed of each and every server, to the primaries and secondaries before the control was returned to the application. For completing the application before control is returned to the application, issue an update command or a write command to the primary and control is not returned to document and if all the process works properly then the durable and constant undergo properly.

    MongoDB will take that update and apply it to the primary, replicate it to the secondaries and so on everything will be consistent. There is a slight chance, however, if a primary fails before the document has been made durable on the disk and that record will be lost. MongoDB then continues and replicates to the rest of the secondaries, but the control has already been returned to the application.

     Key Points

    MongoDB Consistency – Represents the guarantee feature of MongoDB.

    Consistency Monotonic Reads – Provides a standalone mongod instance.

    Consistency for Multiple Servers – Termed as eventual consistency.

    2.4 Load balancing

    MongoDB scales horizontally using sharding. The user chooses a shard key, which determines how the data in a collection will be distributed. The data is split into ranges (based on the shard key) and distributed across multiple shards. (A shard is a master with one or more replicas.). Alternatively, the shard key can be hashed to map to a shard – enabling an even data distribution.

    MongoDB can run over multiple servers, balancing the load or duplicating data to keep the system up and running in case of hardware failure.

    2.5 File storage

    MongoDB can be used as a file system, called GridFS, with load balancing and data replication features over multiple machines for storing files.

    This function, called grid file system, is included with MongoDB drivers. MongoDB exposes functions for file manipulation and content to developers. GridFS can be accessed using mongofiles utility or plugins for Nginx and lighttpd. GridFS divides a file into parts, or chunks, and stores each of those chunks as a separate document.

    2.6 Aggregation

    MongoDB provides three ways to perform aggregation: the aggregation pipeline, the map-reduce function, and single-purpose aggregation methods.

    Map-reduce can be used for batch processing of data and aggregation operations. But according to MongoDB's documentation, the Aggregation Pipeline provides better performance for most aggregation operations.

    The aggregation framework enables users to obtain the kind of results for which the SQL GROUP BY clause is used. Aggregation operators can be strung together to form a pipeline – analogous to Unix pipes. The aggregation framework includes the $lookup operator which can join documents from multiple collections, as well as statistical operators such as standard deviation.

    2.7 Server-side Javascript execution

    JavaScript can be used in queries, aggregation functions (such as MapReduce), and sent directly to the database to be executed.

    2.8 Capped collections

    MongoDB supports fixed-size collections called capped collections. This type of collection maintains insertion order and, once the specified size has been reached, behaves like a circular queue.

    2.9 Transactions

    Support for multi-document ACID transactions was added to MongoDB with the General Availability of the 4.0 release in June 2018.

    3. References

    https://www.splessons.com/lesson/mongodb-consistency/#targetText=MongoDB%20Consistency%20is%20one%20of,back%20the%20last%20upgraded%20esteems.

    https://www.tutorialsjar.com/key-features-of-mongodb/

    https://searchdatamanagement.techtarget.com/definition/MongoDB

    https://www.tutorialspoint.com/mongodb/mongodb_advantages.htm

    https://www.alibabacloud.com/blog/high-availability-mongodb-cluster-configuration-solutions_490866

    https://docs.mongodb.com/manual/replication/

    https://www.guru99.com/what-is-mongodb.html

    https://www.intertech.com/Blog/what-is-mongodb-explaining-the-rise-of-nosql/

    https://en.wikipedia.org/wiki/MongoDB

    https://www.mongodb.com/what-is-mongodb

    https://stackoverflow.com/questions/11292215/where-does-mongodb-stand-in-the-cap-theorem

    https://medium.com/@Alibaba_Cloud/high-availability-mongodb-cluster-configuration-solutions-465cc82cd0bc

    'DB > Nosql' 카테고리의 다른 글

    MongoDB Arbiter  (0) 2020.04.10
    Elasticsearch  (0) 2020.03.03
    MongoDB Transactions  (0) 2020.02.23
    MongoDB vs Casandra  (0) 2019.09.30
    Difference between Nosql and SQL  (0) 2019.08.25

    댓글

Designed by Tistory.