Connect the global distribution database with Spring-mongodb Cosmos DB (1)

Source: Internet
Author: User
Tags mongodb interface azure cosmos db

Distributed system has always been very complex, especially the distributed database system, how do you guarantee the consistency of data? How do you guarantee its performance and latency? How do you achieve global distribution without requiring customers to do complex configuration? Under the theorem of CAP, how to design and choose the distributed database system? Azure Cosmos DB provides customers with a global distributed database service in the simplest way to support custom consistency, guaranteed latency, and spring is one of the Java developers ' favorite open source frameworks, and this article focuses on using spring MongoDB to access Azure Cosmos DB MongoDB Model:

    • How to create and configure a MongoDB database for Azure Cosmos db
    • How to access Cosmos DB using the standard SPRING-MONGODB framework and Spring boot
    • How to configure the global distribution model for Azure Cosmos db
    • How spring apps and MongoDB tools access the Cosmos DB distribution database
About Azure Cosmos db

Azure's Cosmos DB is a globally distributed, massively scalable, multi-model supported database service provided by Microsoft, and applications such as the popular IoT services, Internet applications, e-commerce sites, etc. can be supported by Cosmos DB, which currently supports the table interface. Gremlin graph calculation, MONGODB interface, SQL interface, etc.:

Spring Boot and Spring MongoDB

For Java developers, the spring framework is probably the most popular open source framework, with countless sub-projects and open-source frameworks based on an elegant programming framework of IOC and AOP, which greatly simplifies the development process and workload of Java developers. Spring boot, which is now strongly promoted by the spring community, further pushes the fast-building development model of spring applications:

Create and configure a MongoDB database for Azure Cosmos db

    1. Login to the century-connected China Azure (https://portal.azure.cn), of course, if you have an overseas Azure account is the same, select New, Database, select Azure Cosmos db to create the "create":

    1. Enter your Cosmos DB name in the ID section, as described earlier, Cosmos DB is a multi-model database, so in the API section select "MongoDB", then enter the resource group name, select the location, click OK to create:

    1. After the creation is complete, it will automatically jump to the Database Administration home page and select "Add Collection" on the home page to create a new database and collection:

Please note:

    • Cosmosdb there is no limit to capacity size, the default is up to 10TB, but if you need higher storage, you can submit a support request increase
    • The initial throughput is a request unit that is pre-allocated to the collection and defaults to 100000 ru/s, but if higher storage is required, a support request can be submitted for increased
    • In the process of creating and configuring the database, the partition key is unique, very important configuration item, in subsequent chapters I will specifically, use the device number as partition key

    1. After the creation, we need to get a string to link to cosmosdb, one way is to choose "Connection string" on the left side of the interface, you can see the host, username, port, password, etc., and the other way is to provide a more convenient way for Cosmosdb, choose "Quick Start", Provides initialization and connection strings directly for different languages:

The next section describes how to use spring development to access Azure Cosmos DB using Spring-mongodb.

Connect the global distribution database with Spring-mongodb Cosmos DB (1)

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.