Latest Version - 4.4
MongoDB ATLAS - Atlas takes care of time-consuming costly administration tasks and get the database resources you need quickly
MongoDB Cloud Providers - AWS, Google Cloud, Azure
Why MongoDB No SQL database?
- Performance - A single object document retrieved from a single place in a disk compared to SQL database where data is spread across multiple tables which in turn needs to access multiple places in the disk to retrieve data.
- Scalability - No SQL databases are compared to be more scalable than SQL databases. For eg. Mongo DB has built-in support for replication and sharding (horizontal partitioning of data) for scalability. Hugh amount of hardware and human resources are needed for SQL databases to support scalability.
- Replication - Has Inbuilt functionality to replicate data to multiple servers for better availability (24*7), No downtime needed for maintenance, Disaster Recovery
- No need to ORM layer which reduces overhead compares to SQL where ORM should be maintained
- Easy document data model (one model for the entire document)
- Easy to use and efficient drivers and frameworks for different languages (c#, java, PHP, Go, JS)
- ACID compliance on a single document
- Flexible - Adapt to change in business needs
- Versatile - JSON Documents, Key-Value, Text, GeoSpatial, Graph, Tabular
- Need ACID compliancy (Atomicity, Consistency, Isolation, Durability). It reduces anomalies and protects the integrity of the database.
- Your data is structured and unchanging - when there is no need to support a variety of data types and when not handling high traffic volume
- Storing a huge volume of data without structure - No SQL does not have a limit of storing multiple data types and can add new types based on business needs
- Maximum size of a document - 16MB. But can store bigger docs using an API which splits the docs into multiple chunks (ex. image > 200MB)
Replication is the process of synchronizing data across multiple servers thereby providing redundancy to protect from data loss and better availability. A Mongo DB can have 2-50 replica sets. The most common is 3 nodes (1 primary and 2 secondaries). Availability increases when more secondary nodes are added to the cluster. You can also separate secondary nodes for DATA ANALYTICS(only READ and no writes) to increase the performance
How Replication works in Mongo DB:
All write operations go only to the primary node and data replicates from primary to the secondary node. During failure or maintenance, the secondary nodes vote and elect a node as a primary node. After the failed node is recovered, it again joins the replica set and works as a secondary node. (Failed node is automatically restarted by the Mongo driver). Replica sets can be in the same data center location or geographically distributed
Sharding
Storing data records across multiple machines to meet the demands of data growth. As the size of the data increases, a single machine may not be sufficient to store the data and provide R/W throughput. Sharding uses horizontal scaling for solving this problem.
Comments
Post a Comment