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!
Working with AWS Networking & Amazon VPC
Being able to architect your own isolated segment of AWS is a simple process using VPCs; understanding how to architect its related networking components and connectivity architecture is key to making it a powerful service.Many services within Amazon Web Services (AWS) require you t...
AWS Compute Fundamentals Update
AWS is renowned for the rate at which it reinvents, revolutionizes, and meets customer demands and expectations through its continuous cycle of feature and service updates. With hundreds of updates a month, it can be difficult to stay on top of all the changes made available. Here ...
10 Steps for an Effective Reserved Instances Strategy
Amazon Web Services (AWS) offers three different ways to pay for EC2 Instances: On-Demand, Reserved Instances, and Spot Instances. This article will focus on effective strategies for purchasing Reserved Instances. While most of the major cloud platforms offer pre-pay and reservation dis...
AWS Certification Practice Exam: What to Expect from Test Questions
If you’re building applications on the AWS cloud or looking to get started in cloud computing, certification is a way to build deep knowledge in key services unique to the AWS platform. AWS currently offers 11 certifications that cover major cloud roles including Solutions Architect, De...
AWS Certified Solutions Architect Associate: A Study Guide
The AWS Solutions Architect - Associate Certification (or Sol Arch Associate for short) offers some clear benefits: Increases marketability to employers Provides solid credentials in a growing industry (with projected growth of as much as 70 percent in five years) Market anal...
Moving Data to S3 with Apache NiFi
Moving data to the cloud is one of the cornerstones of any cloud migration. Apache NiFi is an open source tool that enables you to easily move and process data using a graphical user interface (GUI). In this blog post, we will examine a simple way to move data to the cloud using NiFi c...
Amazon DynamoDB: 10 Things You Should Know
Amazon DynamoDB is a managed NoSQL service with strong consistency and predictable performance that shields users from the complexities of manual setup.Whether or not you've actually used a NoSQL data store yourself, it's probably a good idea to make sure you fully understand the key ...
The 11 AWS Certifications: Which is Right for You and Your Team?
As companies increasingly shift workloads to the public cloud, cloud computing has moved from a nice-to-have to a core competency in the enterprise. This shift requires a new set of skills to design, deploy, and manage applications in cloud computing.As the market leader and most ma...
Aviatrix Integration of a NextGen Firewall in AWS Transit Gateway
Learn how Aviatrix’s intelligent orchestration and control eliminates unwanted tradeoffs encountered when deploying Palo Alto Networks VM-Series Firewalls with AWS Transit Gateway.Deploying any next generation firewall in a public cloud environment is challenging, not because of the f...
AWS Config Best Practices for Compliance
Use AWS Config the Right Way for Successful ComplianceIt’s well-known that AWS Config is a powerful service for monitoring all changes across your resources. As AWS Config has constantly evolved and improved over the years, it has transformed into a true powerhouse for monitoring your...
Cloud Academy is Coming to the AWS Summits in Atlanta, London, and Chicago
Cloud Academy is a proud sponsor of the 2019 AWS Summits in Atlanta, London, and Chicago. We hope you plan to attend these free events that bring the cloud computing community together to connect, collaborate, and learn about AWS. These events are all about learning. You can learn how t...
How to Monitor Your AWS Infrastructure
The AWS cloud platform has made it easier than ever to be flexible, efficient, and cost-effective. However, monitoring your AWS infrastructure is the key to getting all of these benefits. Realizing these benefits requires that you follow AWS best practices which constantly change as AWS...