Top Cosmos DB Interview Questions (2021) | CodeUsingJava
















Most frequently asked Cosmos DB Interview Questions


  1. What is Cosmos DB?
  2. Explain the common use cases for Azure Cosmos DB?
  3. How does Cosmos DB cost is calculated?
  4. How does Cosmos Db Offer predictable performance?
  5. What does it mean that Azure Cosmos DB is multi-model?
  6. Limits Of Azure Cosmos Db?
  7. What are Master key tokens?
  8. How does a master key works in cosmos db?
  9. What are Authorization header?
  10. How do i sign up for Cosmos Db?
  11. What is the difference between Microsoft Azure DocumentDB vs Azure Table Storage?
  12. Explain the indexing in Cosmos DB.
  13. How do i start developing against the documentdb Api?


What is Cosmos DB?

Azure Cosmos DB is commonly used within web and mobile applications, and is well suited for modeling social interactions, integrating with third-party services, and for building rich personalized experiences. The Cosmos DB SDKs can be used build rich iOS and Android applications using the popular Xamarin framework.
Azure Cosmos DB is a fully managed NoSQL database for modern app development. Single-digit millisecond response times, and automatic and instant scalability, guarantee speed at any scale. Business continuity is assured with SLA-backed availability and enterprise-grade security.


Explain the common use cases for Azure Cosmos DB?

  • low and fast order of millisecond response times.
  • predictable performance
  • to automatic scale rapidly and globally
  • ability to query over schema-free data

How does Cosmos DB cost is calculated?

The cost of all database operations is normalized and expressed as request units. Azure Cosmos DB offers two database operations models:
Provisioned Throughput is measured in request units per second (RU/s) and billed per hour. Serverless bills for the request units used for each database operation.


How does Cosmos Db Offer predictable performance?

A request unit (RU) is the measure of throughput in Azure Cosmos DB. A 1-RU throughput corresponds to the throughput of the GET of a 1-KB document. Every operation in Azure Cosmos DB, including reads, writes, SQL queries, and stored procedure executions, has a deterministic RU value that's based on the throughput required to complete the operation. Instead of thinking about CPU, IO, and memory and how they each affect your application throughput, you can think in terms of a single RU measure.You can reserve each Azure Cosmos DB container with provisioned throughput in terms of RUs of throughput per second.You can also scale up or scale down your container's throughput as the needs of your application evolve.

What does it mean that Azure Cosmos DB is multi-model?

Multi model database service means that your data can be stored a number of different ways. Currently, Cosmos DB stores 4 different types of data and it allows you to integrate with an API and build out a user experience around these database storage types.

Limits Of Azure Cosmos Db?

There is no limit to the total amount of throughput that a container can support in Azure Cosmos DB. The key idea is to distribute your workload roughly evenly among a sufficiently large number of partition keys.

What are Master key tokens?

The master key token is the all access key token that allows users to have full control of Cosmos DB resources in a particular account. The master key is created during the creation of an account. There are two sets of master keys, the primary key and the secondary key. The administrator of the account can then exercise key rotation using the secondary key.
The account administrator can also regenerate the keys as needed.


How does a master key works in cosmos db?

The master key token is the all access key token that allows users to have full control of Cosmos DB resources in a particular account. The master key is created during the creation of an account. There are two sets of master keys, the primary key and the secondary key.

Cosmos DB Interview Questions


What are Authorization header?

All REST operations, whether you're using a master key token or resource token, must include the authorization header with the authorization string in order to interact with a resource.
The parts enclosed in brackets are as follows:
  • {typeoftoken} denotes the type of token: master or resource.
  • {tokenversion} denotes the version of the token, currently 1.0.
  • {hashsignature} denotes the hashed token signature.
The authorization string should be encoded before adding it to the REST request to ensure that it contains no invalid characters.

How do i sign up for Cosmos Db?

Azure Cosmos DB is available in the Azure portal. First, sign up for an Azure subscription. After you've signed up, you can add a DocumentDB API, Graph API (Preview), Table API, or MongoDB API account to your Azure subscription.

What is the difference between Microsoft Azure DocumentDB vs Azure Table Storage?

Both are NoSQL technologies, but they are massively different. Azure Tables is a simple Key/Value store and does not support complex functionality like complex queries (most of them will require a full partition/table scan anyway, which will kill your performance and your cost savings), custom indexing (indexing is based on PartitionKey and RowKey only, you currently can't index on any other entity property and searching for anything other than PartitionKey/RowKey combination will require a partition/table scan), or stored procedures.
If your data needs are simple (like in the example above), then Azure Tables provide what you need, you might end up using that in favor of DocDB due to pricing, performance and storage capacity.

Explain the indexing in Cosmos DB.

Azure Cosmos DB is a schema-agnostic database that allows you to iterate on your application without having to deal with schema or index management. By default, Azure Cosmos DB automatically indexes every property for all items in your container without having to define any schema or configure secondary indexes. The goal of this article is to explain how Azure Cosmos DB indexes data and how it uses indexes to improve query performance. It is recommended to go through this section before exploring how to customize indexing policies.

Cosmos DB Interview Questions


How do i start developing against the documentdb Api?

Microsoft DocumentDB API is available in the Azure portal. First you must sign up for an Azure subscription. Once you sign up for an Azure subscription, you can add DocumentDB API container to your Azure subscription. For instructions on adding an Azure Cosmos DB account, see Create an Azure Cosmos DB database account.
SDKs are available for .NET, Python, Node.js, JavaScript, and Java. Developers can also use the RESTful HTTP APIs to interact with Azure Cosmos DB resources from various platforms and languages.