Azure Cosmos DB

Azure Cosmos DB is a globally distributed, multi-model NoSQL database service designed for high performance and scalability. Unlike traditional relational databases, Cosmos DB allows for flexible schema definitions, enabling you to store diverse data without the constraints of predefined schemas.

Advantages of Azure Cosmos DB

  1. No Schema & Index Management:
    • Fully schema-agnostic, eliminating the need for schema and index management.
    • Minimizes application downtime during schema migrations.
  2. Industry-Leading Comprehensive SLAs:
    • Guarantees high availability of 99.99%, read and write latencies at the 99th percentile, consistent throughput, and strong consistency.
  3. Low Total Cost of Ownership:
    • As a fully managed service, it reduces the complexity and cost associated with managing multi-datacenter deployments, upgrades, and support.
  4. Development Using NoSQL APIs:
    • Supports various APIs, including Cassandra, MongoDB, Gremlin, and Azure Table Storage, allowing developers to work with familiar tools.
  5. Global Distribution:
    • Easily add or remove Azure regions to your Cosmos account with a single click, facilitating seamless global distribution of data.

Cosmos Database Structure

  • Database:
    • Acts as a namespace and is the unit of management for sets of Azure Cosmos containers. You can create multiple databases within a Cosmos account.
  • Cosmos Account:
    • The foundational unit for global distribution and high availability. It allows you to manage data and throughput across multiple Azure regions.
  • Container:
    • The unit of scalability for both provisioned throughput and storage. Containers can be horizontally partitioned and replicated across regions.

Global Distribution and Partitioning

  • Logical Partitions:
    • Cosmos DB uses logical partitioning within a container to efficiently distribute items based on partition keys. Each logical partition can reside in a physical partition, allowing for effective load distribution.
  • Physical Partitions:
    • Containers can hold millions of items, organized into logical partitions, enhancing performance and scalability.

Types of Consistency

Azure Cosmos DB offers a spectrum of consistency levels, ranging from strong consistency to eventual consistency, along with several intermediate options. This allows you to choose the appropriate consistency level for your application needs:

  • Strong Consistency: Guarantees linearizability and the highest level of consistency.
  • Eventual Consistency: Provides the lowest level of consistency but allows for maximum availability and performance.

The chosen consistency level is guaranteed across all read operations, irrespective of the region.

Request Units (RUs)

  • Throughput is provisioned and billed on an hourly basis based on Request Units (RUs).
  • The cost of database operations is normalized and expressed in RUs, with each operation assigned a specific RU cost depending on the type, size of the item, consistency level, and query patterns.
  • For example, reading a 1-KB item typically consumes 1 RU.

Creating Azure Cosmos DB Using Azure Portal

  1. Step 1: Click on Create a Resource and search for Azure Cosmos DB, then click on Create.
  2. Step 2: Fill in the required details and click on Review + Create to check for any missing information.
  3. Step 3: Configure the network settings for Azure Cosmos DB.
  4. Step 4: Click on the Create button to initiate the creation of your Cosmos DB instance.
  5. Step 5: Upon successful deployment, you will see a confirmation window indicating the successful creation of your Azure Cosmos DB.