Understanding Cosmos DB

Cosmos DB storage is the premium offering for Azure Table storage. It's a multimodel and globally distributed database service that is designed to horizontally scale and replicate your data to any number of Azure regions. By replicating and scaling the data, Cosmos DB can guarantee low latency, high availability, and high performance anywhere in the world. You can replicate or scale data easily inside the Azure portal by selecting the available regions on the map.

This high availability and low latency makes Cosmos DB most suitable for mobile applications, games, and applications that need to be globally distributed. The Azure portal also uses Cosmos DB for data storage. Cosmos DB is completely schemaless, and you can use a number of existing APIs with available SDKs to communicate with it. So, if you are using a specific API for your data and you want to move your data to Cosmos DB, all you need to do is change the connection string inside your application and the data is stored in Cosmos DB automatically.

Cosmos DB offers the following key benefits:

  • Turnkey global distribution: With Cosmos DB, you can build highly responsive and highly available applications that scale globally. All data is transparently replicated to the regions where your users are, so they can interact with a replica of the data that is closest to them. Azure regions can easily be added and removed. Data will then seamlessly replicate to the selected regions without any downtime of the application. 
  • Always on: Cosmos DB provides an SLA with 99.99% high availability for both reads and writes. To ensure that your application is designed to fail over in case of regional disasters, Cosmos DB provides the ability to invoke regional failover using the Azure portal, or programmatically.
  • Worldwide elastic scalability of throughput and storage: Elastic scalability to both reads and writes is offered by Cosmos DB. By a single API call, you can elastically scale up from thousands to hundreds of millions of requests per second around the globe, and you only pay for the throughput and storage you need.
  • No schema or index management: With Cosmos DB, you don't have to deal with schema or index management, which is a painful process for globally distributed apps. Without schema and index management, there is also no downtime for applications while migrating schemas. Cosmos DB automatically indexes all data and serves queries fast.
  • Secured by default: All data in Cosmos DB is encrypted at rest and in motion. Cosmos also provides row-level authorization.

Cosmos DB supports the following APIs for storing and interacting with your data:

  • SQL API: With the SQL API, you can use SQL queries as a JSON query language against the dataset inside Cosmos DB. Because Cosmos DB is schemaless, it provides autoindexing of the JSON documents. Data is stored on SSD drives for low latency, and it is lock-free, so you can create real-time queries for your data. Cosmos DB also supports writing stored procedures, triggers, and user-defined functions (UDFs) in JavaScript, and it supports ACID (short for Atomicity, Consistency, Isolation, Durability) transactions inside a collection.
  • MongoDB API: MongoDB is an open source document database that provides high performance, high availability, and automatic scaling by default. Using it inside Cosmos DB provides automatic sharding, indexing, replication, and
    encryption of your data on top of this. MongoDB also provides an aggregation pipeline that can be used to filter and transform the data in multiple stages. It also supports creating a full-text index, and you can integrate it easily with Azure Search and other Azure services as well.
  • Gremlin (Graph) API: The Gremlin API is part of the Apache TinkerPop project, which is an open source graph computing framework. A graph is a way of storing objects (nodes) based on relationships. Each object can have multiple relations with other objects. You can interact with the data using JavaScript.
  • Table API: The Azure Table API can be used for applications that are written for using Azure Table storage, but need the premium features, such as global distribution, automatic indexing, low latency, and high throughput.
  • Cassandra API: The Cassandra API can be used for applications that are written for Apache Cassandra. Apache Cassandra is an open source distributed NoSQL database that offers scalability and high availability. Cosmos DB offers no operations management, SLA, and automatic indexing on top of this.
  • Etcd API (preview): The etcd API, allows you to use Azure Cosmos DB as the backend store for Azure Kubernetes. In Kubernetes, etcd is used to store the state and the configuration of the Kubernetes clusters. Azure Cosmos DB implements the etcd wired protocol. Developers can use this API to scale Kubernetes state management worldwide using Cosmos DB.

In the future, new APIs will be added to Cosmos DB as well.

In the next section, we are going to create, read, update, and delete data by using appropriate APIs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset