If you’re interested in learning how consistency models on AWS can help you write stable, reliable applications, then this is the article for you. By following a consistency model, your application’s memory will remain consistent and the results of any operations on its memory should be predictable. (Editor’s Note: This is complex material. If you’d like to brush up on your understanding of storage in AWS, check out this course.)
Consistency Models Create Structure and Rules around Memory to Ensure Application Reliability
In very simple terms, consistency models define rules for the order and visibility of read and updates.
Distributed systems are large and replicated across many servers, allow concurrent execution of components, are prone to failure, experience transaction delays, and have no global time. Objects in a distributed storage system are replicated to avoid single-point failures and improve both reliability and availability to avoid overload of transactions in a single system and to give faster access to local copies to avoid communication delay.
But all these virtues of a distributed system come at a price as multiple copies of data need to be kept identical. This requirement brought the necessities of a suitable consistency model for different distributed services such as storage, memory, or a NoSQL offering.
Broadly speaking, there are two types of consistency models: Data-centric and client-centric. Let’s take a look at both of them.
Data-Centric Consistency Models
Tanenbaum & Maarten Van Steen, two computer scientists who are experts in this field, define the consistency model as a contract between the software (processes) and memory implementation (data store). This model guarantees that if the software follows certain rules, the memory works correctly. Since, in a system without a global clock, defining the last operation writes is difficult, some restrictions should be applied on the values that can be returned by a read operation.
The following models are the data-centric consistency models according to their strictness in descending order – the strictest models are listed first:
|Strict Consistency||Absolute time ordering of all shared accesses matters|
|Linearizability Consistency||All processes must see all shared accesses in the same order. Accesses are furthermore ordered according to a (non-unique) global timestamp|
|Sequential Consistency||All processes see all shared accesses in the same order. Accesses are not ordered in time|
|Causal Consistency||All processes see causally-related shared accesses in the same order.|
|FIFO Consistency||All processes see writes from each other in the order they were used. Writes from different processes may not always be seen in that order|
|Weak Consistency||Shared data can be counted on to be consistent only after a synchronization is done|
|Release Consistency||Shared data are made consistent when a critical region is exited|
|Entry Consistency||Shared data pertaining to a critical region are made consistent when a critical region is entered.|
Client-Centric Consistency Models
In a client-centric consistency model, the emphasis is put on how data is seen by the clients. The data can be varying from clients to clients if data replication is not complete. Faster data access is the primary concern, so we might opt for a less-strict consistency model such as eventual consistency.
In this approach,the system informally ensures that, if no new updates are made to a particular piece of data, eventually all reads to that item will return the last updated value. The updated replicas send the update messages to all other replicas. In these states different replicas could return different values if queried, but eventually all the replicas get the update and will be consistent. This model is suitable for hundreds of thousands of concurrent reads are writes per second such as Twitter updates, Instagram photo uploads, Facebook status pages, messaging systems, and so on where data integrity concern is not paramount.
RYW (Read-Your-Writes) consistency is achieved when the system guarantees that, once a record has been updated, any attempt to read the record will return the updated value. RDBMS generally gives read-your-write consistency.
Read-after-write consistency is stricter than eventual consistency. A newly inserted data item or record will be immediately visible to all the clients. Please note that it is only applicable to new data. Updates and deletions are not considered in this model.
Amazon S3 Consistency Models
Amazon S3 provides read-after-write consistency for PUTS of new objects in your S3 bucket and eventual consistency for overwrite PUTS and DELETES in all regions. So, if you add a new object to your bucket, you and your clients will see it. But, if you overwrite an object, it might take some time to update its replicas – hence the eventual consistency model is applied.
Amazon S3 guarantees high-availability by replicating data across many servers and AZs. It is obvious that data integrity should be maintained if a new record is added or a record/data is updated and deleted. The scenarios for above cases are as follows:
- A new PUT request is made. The object might not appear in the list if queried immediately until the changes are propagated to all the servers and AZs. The read-after-write consistency model is applied here.
- An UPDATE request is made. As eventual consistency model is applied for UPDATEs, a query to list the object might return an old value.
- A DELETE request is made. As eventual consistency model is applied for DELETEs, a query to list or read the object might return the deleted object.
Amazon DynamoDB Consistency Models
Amazon DynamoDB is one of the most popular NoSQL service from AWS. NoSQL storage is inherently distributed. To enable high availability and data durability, Amazon DynamoDB stores three geographically distributed replicas of each table. A write operation in DynamoDB adheres to eventual consistency. A read operation (GetItem, BatchGetItem, Query or Scan operations) on DyanamoDB table is eventual consistent read by default. But, you can configure a strong consistent read request for the most recent data. Note that a strong consistent read operation consumes twice the read units than eventual consistent read request. In general, it is advised to follow eventual consistent read because the change propagation in DynamoDB is very fast (DynamoDB uses SSDs for low-latency) and you will get the same result with the half of the cost of a strong read consistent request.
Phew! That was a lot of information. I hope you now have at least some idea about the different types of consistency models. AWS’s distributed paradigm means its services have to adopt consistency models which best suits the performance and consistency of data or objects.
Want to learn more? Try Cloud Academy for free for 7-days. Here are a few courses and learning paths that might interest you:
- Database Fundamentals for AWS
- How to Architect with a Design for Failure Approach
- Learning Path: Fundamentals of AWS
You’ll learn everything you need to know to successfully develop reliable and dependable AWS applications – as well as pass AWS certification exams on the first try. We look forward to working together with you to upgrade your career!
Which Certifications Should I Get?
As we mentioned in an earlier post, the old AWS slogan, “Cloud is the new normal” is indeed a reality today. Really, cloud has been the new normal for a while now and getting credentials has become an increasingly effective way to quickly showcase your abilities to recruiters and compan...
New Content: AWS, Azure, Typescript, Java, Docker, 13 New Labs, and Much More
This month, our Content Team released a whopping 13 new labs in real cloud environments! If you haven't tried out our labs, you might not understand why we think that number is so impressive. Our labs are not “simulated” experiences — they are real cloud environments using accounts on A...
Kickstart Your Tech Training With a Free Week on Cloud Academy
Are you looking to make a jump in your technical career? Want to get trained or certified on AWS, Azure, Google Cloud Platform, DevOps, Kubernetes, Python, or another in-demand skill?Then you'll want to mark your calendar. Starting Monday, June 22 at 12:00 a.m. PDT (3:00 a.m. EDT), ...
New Content: AZ-500 and AZ-400 Updates, 3 Google Professional Exam Preps, Practical ML Learning Path, C# Programming, and More
This month, our Content Team released tons of new content and labs in real cloud environments. Not only that, but we introduced our very first highly interactive "Office Hours" webinar. This webinar, Acing the AWS Solutions Architect Associate Certification, started with a quick overvie...
Azure vs. AWS: Which Certification Provides the Brighter Future?
More and more companies are using cloud services, prompting more and more people to switch their current IT position to something cloud-related. The problem is most people only have that much time after work to learn new technologies, and there are plenty of cloud services that you can ...
Blog Digest: 5 Reasons to Get AWS Certified, OWASP Top 10, Getting Started with VPCs, Top 10 Soft Skills, and More
Thank you for being a valued member of our community! We recently sent out a short survey to understand what type of content you would like us to add to Cloud Academy, and we want to thank everyone who gave us their input. If you would like to complete the survey, it's not too late. It ...
New Content: Alibaba, Azure Cert Prep: AI-100, AZ-104, AZ-204 & AZ-400, Amazon Athena Playground, Google Cloud Developer Challenge, and much more
This month, our Content Team released 8 new learning paths, 4 courses, 7 labs in real cloud environments, and 4 new knowledge check assessments. Not only that, but we introduced our very first course on Alibaba Cloud, and our expert instructors are working 'round the clock to create 6 n...
Top 5 Reasons to Get AWS Certified Right Now
Cloud computing trends are on the rise and have been for some time already. Fortunately, it’s never too late to start learning cloud computing. Skills like AWS and others associated with cloud computing are in high demand because cloud technologies have become crucial for many businesse...
Introducing Our Newest Lab Environments: Lab Playgrounds
Want to train in a real cloud environment, but feel slowed down by spinning up your own deployments? When you consider security or pricing costs, it can be costly and challenging to get up to speed quickly for self-training. To solve this problem, Cloud Academy created a new suite of la...
Blog Digest: AWS Breaking News, Azure DevOps, AWS Study Guide, 8 Ways to Prevent a Ransomware Attack, and More
New articles by topicAWS Azure Data Science Google Cloud Cloud Adoption Platform Updates & New Content Security Women in TechAWSBreaking News: All AWS Certification Exams Now Available Online As an Advanced AWS Technology Partner, C...
AWS Certified Solutions Architect Associate: A Study Guide
Want to take a really impactful step in your technical career? Explore the AWS Solutions Architect Associate certificate. Its new version (SAA-C02) was released on March 23, 2020, though you can still take SAA-C01 through July 1, 2020. This post will focus on version SAA-C02.The AWS...
New on Cloud Academy: AWS Solutions Architect Exam Prep, Azure Courses, GCP Engineer Exam Prep, Programming, and More
Free content on Cloud Academy More and more customers are relying on our technology and content to keep upskilling their people in these months, and we are doing our best to keep supporting them. While the world fights the COVID-19 pandemic, we wanted to make a small contribution to he...