noc19-cs33 Lec 15 Consistency Solutions

IIT Kanpur July 201
20 followers
Dec 3, 2023
So, we will see the spectrum of different consistency solutions which are available
under the weak consistency model and we have seen that eventual consistency which is supported
by the Cassandra is at one extreme level and strong consistency at the other extreme level
in between what are the other consistency models are there.
So, before that we have to understand when to use these consistency solutions.
Now if you want to do a faster read and writes obviously the eventual consistency is the
good enough for the faster writes and reads.
Similarly, if we require the achieve the high consistency or strong consistency then we
will be having a slower writes and reads.
Now in between we will see the other forms of consistency and the performance varies
from strong consistency to the weak consistency that means we have to ensure what kind of
reads and write whether it is faster or it is slower read and writes are required.
So eventual consistency Cassandra offers eventual consistency if writes to a key stops
all the replicas of a key will converge eventually.
Originally this eventual consistency was inspired by inspired from Imagen's Dynamo and LinkedIn's
VodalMod system into the Cassandra's design.
So here we have to see that strong eventual consistency supports faster reads and write
operations and let us see between the eventual consistency and between the strong consistency
what are the other weak form of consistency available.
They are called newer consistency model.
So striving towards a strong consistency is very much needed but different applications
but while still trying to maintain high availability and a partition tolerance forces to go for
some weak consistency models.
So there are different models which are shown over here they are called per key sequential
consistency model, then red blue consistency model, then CRDTs and causal consistency model
probabilistic.
Let us see this newer consistency model how they are now trading the consistency and giving
the performance required by the applications.
So as far as the per key sequential consistency model says that per key all the operations
have the global order.
So this ensures a performance better than the eventual consistency because it ensures
the strong consistency notion per key basis at global level.
Now another type of consistency is called CRDTs that is commutative replicated data
types.
Here the data structure for which the commutated writes gives the same result.
This was given by the INRIA France.
For example, if it is the value is integer and only operation allowed is plus 1.
So whether the two writes whether one has happened before the other it does not makes
any difference why because it is only doing the plus operation plus 1 operation increment
operation.
Effectively server do not need have to worry about the consistency if it is the commutative
operations commutative write operations in CRDTs.
Now all the operations cannot be commutative.
So therefore in the red blue consistency it will divide into two different type of
operations as per commutative and the other operations.
So it will rewrite the client's transaction to separate operations into the red operations
that is versus blue operations.
Blue operations can be executed commutated in any order across data center whereas the
red operations need to be executed in the same order in the data center.
So this classification of these operations into the blue and red ensures the red blue
consistency and therefore will make this particular approach that is the red blue consistency
a much faster than eventual means it will ensure a strong a much better consistency
level compared to the eventual consistency.
Now causal consistency, causal consistency deals with the another weak form of consistency
which says that the read must respect the partial order based on the information flow.
For example here we have seen that the client A writes the key 1 as 33 whereas the client
B will read this value of K after some point of time K1.
So it should return the value 33 so obviously this write of a client 1 is causally related.
So client this key writing of key K1 is causally related to the read operation of K1 and this
there is no message exchange but internally we have to see this kind of causal dependency
exist.
Similarly you see that there is a causal flow similarly between client B which reads between
client B and client C which reads this value of K2 which is written by the client B at
this point of time also are causally related.
So that means write of K2 of a key K2 is happened before the read of key K2 in this case.
So this particular read of K2 returns the value which is written by the client B on
key K2 and similarly when the client C performs a read of K1 it must return using this causal
path the value 33 which is written by the client A not the other value which is the
old value which is written as 22.
So the causality where the messages are not exchanged even then the causality is protected
then it is called causal consistency.
So this kind of consistency also is very fast notion of providing read and write although
they are ensuring some strong notion of consistency.
So which model of consistency should be used?
So use the lowest consistency to the left that is the consistency model that is the
correct for your application gets you the faster availability in this particular scenario.
Now what is the strong consistency models?
Let us quickly review them.
So linearizability is the strong consistency model where each operation by the client is
visible to all other.
And just like storing the data on a single system where whenever one data is modified
it is available to all the clients instantaneously and in real time.
If that is there then it is called linearizability is very difficult to achieve in the distributed
systems.
Another form of strong consistency is called sequential consistency which says that the
result of any execution is the same as if the operations of all the processors were
executed in some sequential order and operations of each individual processor appear in this
sequence in the order specified by its program.
Meaning to say that although it is not linearizability approach but the sequential consistency says
that some order which is to be executed in some sequential order across all the clients
then if it is ensured then it is called sequential consistency.
It is given by the Lamport.
So after the fact find reasonable ordering of operations can be reorder operations that
obeys the consistency at all the clients across the clients.
So this is again another form of strong consistency that is sequential consistency.
That means all the clients will see the same kind of the operations by all the clients
called sequential consistency.
Now the transactions which are basically following the ACID properties and whether the newer
SQL stores that is NoSQL stores sometimes called NewSQL which also ensures the ACID
transaction properties.
So nowadays the application which require also the ACID property to be followed besides
all the properties which we have seen in the NoSQL stores if both are in addition to that
ACID is also required and they are called a NewSQL systems.
So for example NewSQL is nowadays is also available in the form of hypertext given by
the kernel and the Spanner database management system using by the Google and transaction
chain by the Microsoft research and they call it as NewSQL which supports besides whatever
is there in NoSQL plus ACID properties to support the transactions.
So in conclusion we have to see that the traditional RDBMS work with a strong consistency model
and offer the ACID properties and whereas the modern workloads do not need such a strong
guarantees but do need fast response that is availability.
The CAP theorem comes into an effect which says that out of consistency availability
and partition you have to choose two of them that we have seen in this part of the discussion.
So NoSQL system which are also called key value store offers the base property that
is called basically available soft state eventual consistency.
So eventual consistency and a variety of other consistency models are striving towards a
strong consistency.
We have also discussed the design details of Cassandra system and also covered different
consistency models which are the newer consistency models which are available for the newer kind
of systems.
Thank you.
