3

What is MongoDB and why use it for modern web applications?

 2 years ago
source link: https://ubuntu.com//blog/what-is-mongodb
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Overview

Organisations of different scales and forms want to harness the power of data to identify new business opportunities and improve current business operations. Organisations that use data effectively can hold a potential advantage – the ability to make faster and more informed business decisions. However, working with data can be a long-standing problem for businesses and functions, especially in data management and software development.

One essential use case in which organisations require fast phase development and excellent data management is building modern web-based applications. Organisations demand a high-quality working system that can be deployed as quickly as possible. In addition, these applications should be able to scale. So, every application must be designed and built on a suitable database. Traditionally, web applications used relational databases as primary data store, with an appreciation for the well-normalised data model. But as applications modernise, more developers lean towards adopting alternative data stores, such as NoSQL (Not Only Structured Query Language) because of their benefits.

One of the applications that can help organisations develop modern web-based applications is MongoDB. This database enables organisations to build scalable and data-driven applications. The data model and persistence strategies are built for high read and write throughput. In addition, it has an automatic failover capability. If you’re wondering what MongoDB is, its benefits, and how MongoDB helps run modern web-based application production, this blog is for you.

What is MongoDB?

MongoDB is an open source NoSQL database management application. NoSQL database systems offer an alternative to traditional relational databases using SQL (Structured Query Language). Data is stored in tables, rows, and columns in a relational database, with relationships between entities. In MongoDB, the data is stored in documents using JSON-like structure to represent and interact with data.

Benefits of using MongoDB

Transactionality and Speed

The most famous feature of MongoDB is its flexible data store because of its JSON-like document format. MongoDB stores records as documents (specifically BSON documents) gathered together in collections. A database holds one or more collections of documents. See the representation of the database, collection, and document below.

Q0nYWmsiQHeBcDKD1jlYGc0288hxYWNfqap5lCbjrp84XqTe6fSJ2zDvnW7LDcQrLQtbNSKl_FIDkhDd2vsbshBV97icjB5Uu1GNgNqpMJwP-7Zj_ZVOuV8pXYtUQ4KbCla9V85q

Given that a document-based data model can represent rich, hierarchical data structures, it’s often possible to model data without the complicated multi-table joins imposed by relational databases. For example, suppose you’re modelling products for an e-commerce web application. With a fully normalised relational data model, products’ information might consist of multiple tables. If you want to get a product representation from the database shell, you will need to write a complicated SQL query full of joins. Consequently, the database setup can be very complex and can slow down development time and the end application.

By contrast, with a document database, the product’s information can be modelled within a single document. Furthermore, the JSON-like structure describes an understandable representation of the products with a hierarchy. In addition, MongoDB’s query capabilities are designed specifically for manipulating both structured documents and unstructured data, which makes it easy for users to use.

Another feature of MongoDB is that it offers an efficient way to search data with text, geospatial, or time-series dimensions. In addition, MongoDB includes features to analyse data, including support for multiple concurrent queries, indexing, and aggregation. Recent versions of MongoDB also include support for distributed, multi-document, multi-collection, multi-database, and multi-shard transactions with a high guarantee of data integrity.

Scalability and High Availability

As web applications, sites, and services become popular and gain more traffic, it is essential to ensure that the databases backing them are scalable to adjust to user demands. Therefore, MongoDB is built on a horizontal scale-out architecture as shown in the figure below. Scaling horizontally means adding more servers to distribute the load across multiple nodes.

6v8ZkGU06PwH0GaL-AZqNeRGHcxLiHETaDaFAa1J54XVhfGHWZms5PKYtQ-GcBKd3dd606BanBrAylz-mR4wPHn1JBRjTuFe5j6XXtZ0RRKXWel1U6IPFjL1V24CFy_CsIGBRasY

Scaling the database horizontally can be achieved in MongoDB through the sharding and replica set features. These scalability features also have benefits for fault tolerance in a MongoDB database deployment. The figure below shows the sharding model.

nuVwgQDEgsc0ZrhQP-plMGSsrg5R2G3_kk4qOwt92XtGAuO1AudVTAqUeHH7QGwsoTcBEVJz8mwVPe0Wi7_vbSxfTef4RV4mBea04vpiS-t8KR_BgXvN5VPGgMM-4vPiUAyJUXNH

Sharding is a method for distributing data across multiple machines. There are various components in a sharded cluster:

  • client – is an application server that uses the drivers such as python, javascript, C#, C++ and more to integrate with the MongoDB router.
  • router (mongos) – it is a mangos operator that acts as an interface between client applications and the sharded cluster.
  • config-server (mongod) – store metadata and configuration settings for the cluster.
  • multiple shards (mongod) – contain a subset of the sharded data, wherein each shard can be deployed as a replica set. The multiple shards represent a horizontal scale-out architecture since shards are deployed in multiple servers.

A replica set is a group of mongod processes that maintain the same data set in a shard or config-server. Replica sets provide redundancy and high availability, and are the basis for all production deployments.  

The scalability and high availability of modern web applications for it to handle a heavy workload, ensure consistent response times, simplify system maintenance, and decrease operational costs. In addition, applications should handle increasing numbers of users that use the applications concurrently. These requirements in terms of scalability are features that MongoDB can support with its horizontal scale-out architecture. Implementing them in web applications can bring numerous advantages for business and, therefore, becomes vital.

Relational databases, on the other hand, can be challenging to set up in a way that distributes data across multiple systems and scales horizontally, in part because of the relational data model. Thus, most SQL database management systems use a scale-up architecture that relies on buying faster, higher-capacity hardware to fulfil usage demands.

Canonical Products for MongoDB

Canonical has developed a comprehensive, cost-effective, and responsive product offering for any MongoDB deployment for organisations to succeed in their data needs. We offer Managed MongoDB, a tailored managed service offering on the cloud or on-premise, with a guaranteed SLA. Additionally, we offer 24/7 MongoDB application support. These offerings are further described below.

MongoDB support 

Canonical provides support to mission-critical MongoDB databases. We can support your on-premise and cloud deployments and a range of other open source applications through our Ubuntu Pro programme. We deliver best in class 24/7 support and security maintenance.

Canonical full-stack support for open source apps comes with guaranteed response times through our subscription SLA.

Learn more about Canonical MongoDB support here.

Managed MongoDB

With the fast-moving nature of the open source, it can be challenging to design, operate, maintain, and secure a robust MongoDB deployment at scale. Canonical’s Managed MongoDB helps organisations get the most from open source, with the lowest risk. By leveraging Canonical’s experience and expertise in open source software, management and operations, customers gain efficiencies and flexibility with no compromise on service delivery.

Whether running on Kubernetes, cloud or on-premise, customers can take advantage of our Managed MongoDB solution. Besides MongoDB, we offer a full range of open source managed application services. Customers can take advantage of Canonical’s expertise as a one-stop-shop for business-critical open source application service delivery.

Learn more about Canonical Managed Applications, including Managed MongoDB here.

Summary 

MongoDB is one of the most popular NoSQL databases and has been widely used in different industries and use cases. As a highly versatile data management solution, MongoDB provides powerful capabilities for scaling, consistency, fault tolerance, agility, and flexibility to facilitate rapid development and low downtime operations. 

Canonical can offer both support and managed services for MongoDB.

Copyright and Trademark

Canonical MongoDB support, Managed Apps and Charm solutions are built by Canonical based on source code published by MongoDB Inc. This product is not endorsed or published by MongoDB, Inc.

MongoDB and the logo are trademarks or registered trademarks of MongoDB Inc. and other parties may also have trademark rights in other terms used herein.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK