Microsoft Azure Cosmos Database Service
This article discusses why and how Azure Cosmos DB was created, as well as how it changed from Document DB to Cosmos DB, which we are familiar with today.
Join the DZone community and get the full member experience.
Join For FreeA NoSQL database with strong consistency is Cosmos DB. It lacks a schema, enables SQL-like querying, and even contains JavaScript-written stored procedures, triggers, and UDFs (User Defined Functions). It's Microsoft's response to systems like MongoDB, Cassandra, Couchbase, and others. For at least 99 percent of requests, Cosmos DB promises latencies of fewer than ten milliseconds for reads and less than 15 milliseconds for writes. With that level of performance assurance, Cosmos DB is poised to rule the planet.
For Cosmos DB, Microsoft also supportss.NET, Node.js, Java, and a Python SDK. It is fully managed and operates on Azure. All the data is automatically replicated across any number of global regions. It offers several different consistency levels.
Features Of Azure Cosmos Database
Strong Consistency
With an RDBMS, it is consistent; therefore, clients should always expect to receive the most recent acknowledged writing when they ask. However, this is slow, and using it requires linking the Cosmos DB account to more than one region.
Bounded Staleness
This level ensures that the readings may be delayed by the client by no more than x versions of the document or a specific amount of time. The user will always receive the most recent two versions of a page, for instance, if the client specifies x=2. With time, it remains the same. If the time is set to five seconds, it will be ensured that the resource has been written to all replicas once every five seconds so that the following queries can see the most recent version.
Session
The most well-known option, this one, is focused on a client session, as the name impliesFor example, imagine that a user of an eCommerce website commented on a product. The user who left the comment ought should be able to read it; however, it will take some time before other page visitors can.
Eventual
The clones will eventually converge, as the name implies, without any further writes. This option is the fastest of all, but it also has the worst read consistency.
Consistent Prefix
You can make sure that the order of writes is always reflected during subsequent reads by using this option.
Multi-Model API Support
In keeping with its planet-scale approach to problem-solving, Cosmos DB offers five of the most widely used categories of APIs for data processing and storage.
High Availability
It provides financially supported SLAs that guarantee resource availability up to the 99th percentile.
The Spectrum of Consistency Models
We have immediate or delayed replication, as was said above in the history lesson. However, Cosmos DB also allows us to select between these two opposites of consistency.
Near-Zero Replication Effort
With a simple click, users and developers may replicate the database to additional locations. The remainder is taken care of by Cosmos DB.
Know HOW, WHEN, and WHY?
Creating a globally distributed application undoubtedly involves comparable challenges. Consider the hypothetical sports channel XYZ that provides real-time information on football games. Its user base is dispersed over more than 50 nations on five continents. Watching live updates for their favorite fixtures on the channel is available to viewers from all over the world. The business is based in North America, where its servers are also located. It appears straightforward at first, but the devil is in the details.
Let's imagine that there is a football game taking place right now. When user A from North America opens the channel, live updates begin to appear. Due to the servers being deployed there, they will experience minimal to no delay. However, if user B from Australia requests live updates, they can experience more delays, depending on the network and the traffic volume. As a result, the user experience in each country will be very different from one another. To address this issue, the sports channel chooses to replicate its servers worldwide to improve user experience and minimize latency for its viewers.
It has a special set of problems that are intrinsic to any replication problem, in addition to the administrative work needed to replicate these servers. When asked how soon the data should be replicated, we must give a detailed answer. You might want to rethink saying "immediately" if you did. Let's say the channel has 60 servers scattered around the globe. If we wish to alter the score on one of these servers, we will need to update the score on each of these 60 servers. If we want to complete this replication instantly, or as we like to say, "in real-time," we must write to those 60 servers right away. Our writing expenses had unexpectedly gone up by $60. After conversion, this
We can avoid this expense, though, provided we can afford a slight delay in replication. For instance, we don't have to write to every server immediately. Data can be replicated one at a time, which again lowers replication costs. However, because the replication is now done one at a time, this method runs the danger of exposing certain users to outdated data. This balancing act represents the classic trade-off between latency and throughput.
We can avoid this expense, though, provided we can afford a slight delay in replication. For instance, we don't have to write to every server immediately. Data can be replicated one at a time, which again lowers replication costs. However, because the replication is now done one at a time, this method runs the danger of exposing certain users to outdated data. This balancing act represents the classic trade-off between latency and throughput.
Let's See the Architecture in Pictorially
Workflow in Azure Cosmos Database
- A user accesses an application through a specific client.
- Azure Traffic Manager uses a routing profile or layered profiles to direct the user's connection to the appropriate place for accessing the application.
- The application creates a database session and connection in the area where the user is directed.
- The solution can support applications with varied degrees of complexity. The app might, for instance, be a straightforward, static page. Or it might be a Kubernetes-hosted micro services-oriented application.
- An Azure Active Directory (Azure AD) user manages the connection between the application landscape and Azure Cosmos DB by retrieving the Azure Cosmos DB keys from the Azure Key Vault.
- Using the Azure Cosmos DB multi-homing APIs, the application can deliver queries to the nearest region because it is aware of it. Without altering settings, the nearest region is found. Your application doesn't need to be redeployed or suspended as regions are added and removed from your Azure Cosmos DB subscription. The application is still quite accessible. On the backend, Azure Cosmos DB manages the data replication and global distribution based on the number of defined regions. The system switches to the region with the greatest failover priority if the automatic failover option is enabled and a region becomes unavailable. For this failover, no user action is necessary. Changing the region priority is possible when automatic failover is enabled.
Worldwide Popular Projects Using Azure Cosmos Database
In applications where lower latency is essential, and data is scattered, Cosmos DB performs exceptionally well. This comprises:
- IoT devices now using Cosmos Database
- Gaming Devices and Applications using Cosmos Database
- Social Media Applications Using Cosmos Database
Microsoft Products Using Microsoft Azure Cosmos Database
Numerous Microsoft products, including the following, have been using Azure Cosmos DB:
- Skype
- Xbox
- Office 365
- Azure
Potential Use Cases
Industries that operate globally and need to keep data close to their users may consider this approach. The media, entertainment, travel, and hospitality sectors are among the examples. Examples of situations where globally distributed applications are used are:
- Streaming video for consumers.
- Services that use apps to pick up and deliver people and goods.
Conclusion
In this introduction to Azure Cosmos DB, it was discussed why and how it was created, as well as how it changed from Document DB to Cosmos DB, which we are familiar with today. We also examined the service's use cases and features.
Opinions expressed by DZone contributors are their own.
Comments