Hubbry Logo
Consistency modelConsistency modelMain
Open search
Consistency model
Community hub
Consistency model
logo
7 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Consistency model
Consistency model
from Wikipedia

In computer science, a consistency model specifies a contract between the programmer and a system, wherein the system guarantees that if the programmer follows the rules for operations on memory, memory will be consistent and the results of reading, writing, or updating memory will be predictable. Consistency models are used in distributed systems like distributed shared memory systems or distributed data stores (such as filesystems, databases, optimistic replication systems or web caching). Consistency is different from coherence, which occurs in systems that are cached or cache-less, and is consistency of data with respect to all processors. Coherence deals with maintaining a global order in which writes to a single location or single variable are seen by all processors. Consistency deals with the ordering of operations to multiple locations with respect to all processors.

High level languages, such as C++ and Java, maintain the consistency contract by translating memory operations into low-level operations in a way that preserves memory semantics, reordering some memory instructions, and encapsulating required synchronization with library calls such as pthread_mutex_lock().[1]

Example

[edit]

Assume that the following case occurs:[2]

  • The row X is replicated on nodes M and N
  • The client A writes row X to node M
  • After a period of time t, client B reads row X from node N

The consistency model determines whether client B will definitely see the write performed by client A, will definitely not, or cannot depend on seeing the write.

Types

[edit]

Consistency models define rules for the apparent order and visibility of updates, and are on a continuum with tradeoffs.[2] There are two methods to define and categorize consistency models; issue and view.

Issue
Issue method describes the restrictions that define how a process can issue operations.
View
View method which defines the order of operations visible to processes.

For example, a consistency model can define that a process is not allowed to issue an operation until all previously issued operations are completed. Different consistency models enforce different conditions. One consistency model can be considered stronger than another if it requires all conditions of that model and more. In other words, a model with fewer constraints is considered a weaker consistency model.

These models define how the hardware needs to be laid out and at a high-level, how the programmer must code. The chosen model also affects how the compiler can re-order instructions. Generally, if control dependencies between instructions and if writes to same location are ordered, then the compiler can reorder as required. However, with the models described below, some may allow writes before loads to be reordered while some may not.

Strong consistency models

[edit]

Strict consistency

[edit]

Strict consistency is the strongest consistency model. Under this model, a write to a variable by any processor needs to be seen instantaneously by all processors.

The strict model diagram and non-strict model diagrams describe the time constraint – instantaneous. It can be better understood as though a global clock is present in which every write should be reflected in all processor caches by the end of that clock period. The next operation must happen only in the next clock period.

In the following diagram, P means "process" and the global clock's value is represented in the Sequence column.

Sequence Strict model Non-strict model
P1 P2 P1 P2
1 W(x)1 W(x)1
2 R(x)1 R(x)0
3 R(x)1

This is the most rigid model. In this model, the programmer's expected result will be received every time. It is deterministic. Its practical relevance is restricted to a thought experiment and formalism, because instantaneous message exchange is impossible. It doesn't help in answering the question of conflict resolution in concurrent writes to the same data item, because it assumes concurrent writes to be impossible.

Sequential consistency

[edit]

The sequential consistency model was proposed by Lamport (1979). It is a weaker memory model than strict consistency model.[3] A write to a variable does not have to be seen instantaneously, however, writes to variables by different processors have to be seen in the same order by all processors. Sequential consistency is met if "the result of any execution is the same as if the (read and write) operations of all processes on the data store were executed in some sequential order, and the operations of each individual processor appear in this sequence in the order specified by its program."[3][4] Adve and Gharachorloo, 1996[5] define two requirements to implement the sequential consistency; program order and write atomicity.

  • Program order: Program order guarantees that each process issues a memory request ordered by its program.
  • Write atomicity: Write atomicity defines that memory requests are serviced based on the order of a single FIFO queue.

In sequential consistency, there is no notion of time or most recent write operations. There are some operations interleaving that is the same for all processes. A process can see the write operations of all processes but it can just see its own read operations. Program order within each processor and sequential ordering of operations between processors should be maintained. In order to preserve sequential order of execution between processors, all operations must appear to execute instantaneously or atomically with respect to every other processor.

These operations need only "appear" to be completed because it is physically impossible to send information instantaneously. For instance, in a system utilizing a single globally shared bus, once a bus line is posted with information, it is guaranteed that all processors will see the information at the same instant. Thus, passing the information to the bus line completes the execution with respect to all processors and has appeared to have been executed. Cache-less architectures or cached architectures with interconnect networks that are not instantaneous can contain a slow path between processors and memories. These slow paths can result in sequential inconsistency, because some memories receive the broadcast data faster than others.

Sequential consistency can produce non-deterministic results. This is because the sequence of sequential operations between processors can be different during different runs of the program. All memory operations need to happen in the program order.

Linearizability[6] (also known as atomic consistency or atomic memory)[7] can be defined as sequential consistency with a real-time constraint, by considering a begin time and end time for each operation. An execution is linearizable if each operation taking place in linearizable order by placing a point between its begin time and its end time and guarantees sequential consistency.

Verifying sequential consistency through model checking is undecidable in general, even for finite-state cache coherence protocols.[8]

Causal consistency

[edit]

Causal consistency[4] defined by Hutto and Ahamad, 1990,[9] is a weakening of the sequential consistency model by categorizing events into those causally related and those that are not. It defines that only write operations that are causally related, need to be seen in the same order by all processes. For example, if an event b takes effect from an earlier event a, the causal consistency guarantees that all processes see event b after event a. Tanenbaum et al., 2007 provide a stricter definition, that a data store is considered causally consistent under the following conditions:[4]

  • Writes that are potentially causally related must be seen by all processes in the same order.
  • Concurrent writes may be seen in a different order on different machines.

This model relaxes sequential consistency on concurrent writes by a processor and on writes that are not causally related. Two writes can become causally related if one write to a variable is dependent on a previous write to any variable if the processor doing the second write has just read the first write. The two writes could have been done by the same processor or by different processors.

As in sequential consistency, reads do not need to reflect changes instantaneously, however, they need to reflect all changes to a variable sequentially.

Sequence P1 P2 P3 P4
1 W(x)1 R(x)1 R(x)1 R(x)1
2 W(x)2
3 W(x)3 R(x)3 R(x)2
4 R(x)2 R(x)3

W(x)2 happens after W(x)1 due to the read made by P2 to x before W(x)2, hence this example is causally consistent under Hutto and Ahamad's definition (although not under Tanenbaum et al.'s, because W(x)2 and W(x)3 are not seen in the same order for all processes). However R(x)2 and R(x)3 happen in a different order on P3 and P4, hence this example is sequentially inconsistent.[10]

Processor consistency

[edit]

In order for consistency in data to be maintained and to attain scalable processor systems where every processor has its own memory, the processor consistency model was derived.[10] All processors need to be consistent in the order in which they see writes done by one processor and in the way they see writes by different processors to the same location (coherence is maintained). However, they do not need to be consistent when the writes are by different processors to different locations.

Every write operation can be divided into several sub-writes to all memories. A read from one such memory can happen before the write to this memory completes. Therefore, the data read can be stale. Thus, a processor under PC can execute a younger load when an older store needs to be stalled. Read before write, read after read and write before write ordering is still preserved in this model.

The processor consistency model[11] is similar to the PRAM consistency model with a stronger condition that defines all writes to the same memory location must be seen in the same sequential order by all other processes. Processor consistency is weaker than sequential consistency but stronger than the PRAM consistency model.

The Stanford DASH multiprocessor system implements a variation of processor consistency which is incomparable (neither weaker nor stronger) to Goodman's definitions.[12] All processors need to be consistent in the order in which they see writes by one processor and in the way they see writes by different processors to the same location. However, they do not need to be consistent when the writes are by different processors to different locations.

Pipelined RAM consistency, or FIFO consistency

[edit]

Pipelined RAM consistency (PRAM consistency) was presented by Lipton and Sandberg in 1988[13] as one of the first described consistency models. Due to its informal definition, there are in fact at least two subtly different implementations,[12] one by Ahamad et al. and one by Mosberger.

In PRAM consistency, all processes view the operations of a single process in the same order that they were issued by that process, while operations issued by different processes can be viewed in different order from different processes. PRAM consistency is weaker than processor consistency. PRAM relaxes the need to maintain coherence to a location across all its processors. Here, reads to any variable can be executed before writes in a processor. Read before write, read after read and write before write ordering is still preserved in this model.

Sequence P1 P2 P3 P4
1 W(x)1
2 R(x)1
3 W(x)2
4 R(x)1 R(x)2
5 R(x)2 R(x)1

Cache consistency

[edit]

Cache consistency[11][14] requires that all write operations to the same memory location are performed in some sequential order. Cache consistency is weaker than processor consistency and incomparable with PRAM consistency.

Slow consistency

[edit]
Slow memory

In slow consistency,[14] if a process reads a value previously written to a memory location, it cannot subsequently read any earlier value from that location. Writes performed by a process are immediately visible to that process. Slow consistency is a weaker model than PRAM and cache consistency.

Example: Slow memory diagram depicts a slow consistency example. The first process writes 1 to the memory location X and then it writes 1 to the memory location Y. The second process reads 1 from Y and it then reads 0 from X even though X was written before Y.

Hutto, Phillip W., and Mustaque Ahamad (1990)[9] illustrate that by appropriate programming, slow memory (consistency) can be expressive and efficient. They mention that slow memory has two valuable properties; locality and supporting reduction from atomic memory. They propose two algorithms to present the expressiveness of slow memory.

Session guarantees

[edit]

These 4 consistency models were proposed in a 1994 paper. They focus on guarantees in the situation where only a single user or application is making data modifications.[15]

Monotonic read consistency

[edit]

If a process reads the value of a data item x, any successive read operation on x by that process will always return that same value or a more recent value.[4]

Monotonic write consistency

[edit]

A write operation by a process on a data item X is completed before any successive write operation on X by the same process.[4]

Read-your-writes consistency

[edit]

A value written by a process on a data item X will always be available to a successive read operation performed by the same process on data item X.[4]

Writes-follows-reads consistency

[edit]

A write operation by a process on a data item x following a previous read operation on x by the same process is guaranteed to take place on the same or a more recent value of x that was read.[4]

Weak memory consistency models

[edit]

The following models require specific synchronization by programmers.

Weak ordering

[edit]

Weak ordering classifies memory operations into two categories: data operations and synchronization operations. To enforce program order, a programmer needs to find at least one synchronisation operation in a program. Synchronization operations signal the processor to make sure it has completed and seen all previous operations done by all processors. Program order and atomicity is maintained only on synchronisation operations and not on all reads and writes. This was derived from the understanding that certain memory operations – such as those conducted in a critical section - need not be seen by all processors until after all operations in the critical section are completed. It assumes reordering memory operations to data regions between synchronisation operations does not affect the outcome of the program. This exploits the fact that programs written to be executed on a multi-processor system contain the required synchronization to make sure that data races do not occur and SC outcomes are produced always.[16]

P1 P2
X = 1;
fence
 
xready = 1;
fence
while (!xready) {}; 
 
fence
 
y = 2;

Coherence is not relaxed in this model. Once these requirements are met, all other "data" operations can be reordered. The way this works is that a counter tracks the number of data operations and until this counter becomes zero, the synchronisation operation isn't issued. Furthermore, no more data operations are issued unless all the previous synchronisations are completed. Memory operations in between two synchronisation variables can be overlapped and reordered without affecting the correctness of the program. This model ensures that write atomicity is always maintained, therefore no additional safety net is required for weak ordering.

In order to maintain weak ordering, write operations prior to a synchronization operation must be globally performed before the synchronization operation. Operations present after a synchronization operation should also be performed only after the synchronization operation completes. Therefore, accesses to synchronization variables is sequentially consistent and any read or write should be performed only after previous synchronization operations have completed.

There is high reliance on explicit synchronization in the program. For weak ordering models, the programmer must use atomic locking instructions such as test-and-set, fetch-and-op, store conditional, load linked or must label synchronization variables or use fences.

Release consistency

[edit]

The release consistency model relaxes the weak consistency model by distinguishing the entrance synchronization operation from the exit synchronization operation. Under weak ordering, when a synchronization operation is to be seen, all operations in all processors need to be visible before the synchronization operation is done and the processor proceeds. However, under the release consistency model, during the entry to a critical section, termed as "acquire", all operations with respect to the local memory variables need to be completed. During the exit, termed as "release", all changes made by the local processor should be propagated to all other processors. Coherence is still maintained.

The acquire operation is a load/read that is performed to access the critical section. A release operation is a store/write performed to allow other processors to use the shared variables.

Among synchronization variables, sequential consistency or processor consistency can be maintained. Using SC, all competing synchronization variables should be processed in order. However, with PC, a pair of competing variables need to only follow this order. Younger acquires can be allowed to happen before older releases.[citation needed]

RCsc and RCpc

[edit]

There are two types of release consistency, release consistency with sequential consistency (RCsc) and release consistency with processor consistency (RCpc). The latter type denotes which type of consistency is applied to those operations nominated below as special.

There are special (cf. ordinary) memory operations, themselves consisting of two classes of operations: sync or nsync operations. The latter are operations not used for synchronisation; the former are, and consist of acquire and release operations. An acquire is effectively a read memory operation used to obtain access to a certain set of shared locations. Release, on the other hand, is a write operation that is performed for granting permission to access the shared locations.

For sequential consistency (RCsc), the constraints are:

  • acquire → all,
  • all → release,
  • special → special.

For processor consistency (RCpc) the write to read program order is relaxed, having constraints:

  • acquire → all,
  • all → release,
  • special → special (except when special write is followed by special read).

Note: the above notation A → B, implies that if the operation A precedes B in the program order, then program order is enforced.

Entry consistency

[edit]

This is a variant of the release consistency model. It also requires the use of acquire and release instructions to explicitly state an entry or exit to a critical section. However, under entry consistency, every shared variable is assigned a synchronization variable specific to it. This way, only when the acquire is to variable x, all operations related to x need to be completed with respect to that processor. This allows concurrent operations of different critical sections of different shared variables to occur. Concurrency cannot be seen for critical operations on the same shared variable. Such a consistency model will be useful when different matrix elements can be processed at the same time.

Local consistency

[edit]

In local consistency,[14] each process performs its own operations in the order defined by its program. There is no constraint on the ordering in which the write operations of other processes appear to be performed. Local consistency is the weakest consistency model in shared memory systems.

General consistency

[edit]

In general consistency,[17] all the copies of a memory location are eventually identical after all processes' writes are completed.

Eventual consistency

[edit]

An eventual consistency[4] is a weak consistency model in a system with the lack of simultaneous updates. It defines that if no update takes a very long time, all replicas eventually become consistent.

Most shared decentralized databases have an eventual consistency model, either BASE: basically available; soft state; eventually consistent, or a combination of ACID and BASE sometimes called SALT: sequential; agreed; ledgered; tamper-resistant, and also symmetric; admin-free; ledgered; and time-consensual.[18][19][20]

Relaxed memory consistency models

[edit]

Some different consistency models can be defined by relaxing one or more requirements in sequential consistency called relaxed consistency models.[7] These consistency models do not provide memory consistency at the hardware level. In fact, the programmers are responsible for implementing the memory consistency by applying synchronization techniques. The above models are classified based on four criteria and are detailed further.

There are four comparisons to define the relaxed consistency:

Relaxation
One way to categorize the relaxed consistency is to define which sequential consistency requirements are relaxed. We can have less strict models by relaxing either program order or write atomicity requirements defined by Adve and Gharachorloo, 1996.[5] Program order guarantees that each process issues a memory request ordered by its program and write atomicity defines that memory requests are serviced based on the order of a single FIFO queue. In relaxing program order, any or all the ordering of operation pairs, write-after-write, read-after-write, or read/write-after-read, can be relaxed. In the relaxed write atomicity model, a process can view its own writes before any other processors.
Synchronizing vs. non-synchronizing
A synchronizing model can be defined by dividing the memory accesses into two groups and assigning different consistency restrictions to each group considering that one group can have a weak consistency model while the other one needs a more restrictive consistency model. In contrast, a non-synchronizing model assigns the same consistency model to the memory access types.
Issue vs. view-based
[14] Issue method provides sequential consistency simulation by defining the restrictions for processes to issue memory operations. Whereas, view method describes the visibility restrictions on the events order for processes.
Relative model strength
Some consistency models are more restrictive than others. In other words, strict consistency models enforce more constraints as consistency requirements. The strength of a model can be defined by the program order or atomicity relaxations and the strength of models can also be compared. Some models are directly related if they apply the same relaxations or more. On the other hand, the models that relax different requirements are not directly related.

Sequential consistency has two requirements, program order and write atomicity. Different relaxed consistency models can be obtained by relaxing these requirements. This is done so that, along with relaxed constraints, the performance increases, but the programmer is responsible for implementing the memory consistency by applying synchronisation techniques and must have a good understanding of the hardware.

Potential relaxations:

  • Write to read program order
  • Write to write program order
  • Read to read and read to write program orders

Relaxed write to read

[edit]

An approach to improving the performance at the hardware level is by relaxing the PO of a write followed by a read which effectively hides the latency of write operations. The optimisation this type of relaxation relies on is that it allows the subsequent reads to be in a relaxed order with respect to the previous writes from the processor. Because of this relaxation some programs like XXX may fail to give SC results because of this relaxation. Whereas, programs like YYY are still expected to give consistent results because of the enforcement of the remaining program order constraints.

Three models fall under this category. The IBM 370 model is the strictest model. A read can be complete before an earlier write to a different address, but it is prohibited from returning the value of the write unless all the processors have seen the write. The SPARC V8 total store ordering model (TSO) model partially relaxes the IBM 370 Model, it allows a read to return the value of its own processor's write with respect to other writes to the same location i.e. it returns the value of its own write before others see it. Similar to the previous model, this cannot return the value of write unless all the processors have seen the write. The processor consistency model (PC) is the most relaxed of the three models and relaxes both the constraints such that a read can complete before an earlier write even before it is made visible to other processors.

In Example A, the result is possible only in IBM 370 because read(A) is not issued until the write(A) in that processor is completed. On the other hand, this result is possible in TSO and PC because they allow the reads of the flags before the writes of the flags in a single processor.

In Example B the result is possible only with PC as it allows P2 to return the value of a write even before it is visible to P3. This won't be possible in the other two models.

To ensure sequential consistency in the above models, safety nets or fences are used to manually enforce the constraint. The IBM370 model has some specialised serialisation instructions which are manually placed between operations. These instructions can consist of memory instructions or non-memory instructions such as branches. On the other hand, the TSO and PC models do not provide safety nets, but the programmers can still use read-modify-write operations to make it appear like the program order is still maintained between a write and a following read. In case of TSO, PO appears to be maintained if the R or W which is already a part of a R-modify-W is replaced by a R-modify-W, this requires the W in the R-modify-W is a ‘dummy’ that returns the read value. Similarly for PC, PO seems to be maintained if the read is replaced by a write or is already a part of R-modify-W.

However, compiler optimisations cannot be done after exercising this relaxation alone. Compiler optimisations require the full flexibility of reordering any two operations in the PO, so the ability to reorder a write with respect to a read is not sufficiently helpful in this case.

Example A
P1 P2
A = flag1 = flag2 = 0
flag1 = 1 flag2 = 1
A = 1 A = 2
reg1 = A reg3 = A
reg2 = flag2 reg4 = flag1
reg1 = 1; reg3 = 2, reg2 = reg4 = 0
Example B
P1 P2 P3
A = B = 0
A = 1
if (A == 1)
B = 1 if (B == 1)
reg1 = A
B = 1, reg1 = 0

Relaxed write to read and write to write

[edit]

Some models relax the program order even further by relaxing even the ordering constraints between writes to different locations. The SPARC V8 partial store ordering model (PSO) is the only example of such a model. The ability to pipeline and overlap writes to different locations from the same processor is the key hardware optimisation enabled by PSO. PSO is similar to TSO in terms of atomicity requirements, in that it allows a processor to read the value of its own write and prevents other processors from reading another processor's write before the write is visible to all other processors. Program order between two writes is maintained by PSO using an explicit STBAR instruction. The STBAR is inserted in a write buffer in implementations with FIFO write buffers. A counter is used to determine when all the writes before the STBAR instruction have been completed, which triggers a write to the memory system to increment the counter. A write acknowledgement decrements the counter, and when the counter becomes 0, it signifies that all the previous writes are completed.

In the examples A and B, PSO allows both these non-sequentially consistent results. The safety net that PSO provides is similar to TSO's, it imposes program order from a write to a read and enforces write atomicity.

Similar to the previous models, the relaxations allowed by PSO are not sufficiently flexible to be useful for compiler optimisation, which requires a much more flexible optimisation.

Relaxing read and read to write program orders: Alpha, RMO, and PowerPC

[edit]

In some models, all operations to different locations are relaxed. A read or write may be reordered with respect to a different read or write in a different location. The weak ordering may be classified under this category and two types of release consistency models (RCsc and RCpc) also come under this model. Three commercial architectures are also proposed under this category of relaxation: the Digital Alpha, SPARC V9 relaxed memory order (RMO), and IBM PowerPC models.

These three commercial architectures exhibit explicit fence instructions as their safety nets. The Alpha model provides two types of fence instructions, memory barrier (MB) and write memory barrier (WMB). The MB operation can be used to maintain program order of any memory operation before the MB with a memory operation after the barrier. Similarly, the WMB maintains program order only among writes. The SPARC V9 RMO model provides a MEMBAR instruction which can be customised to order previous reads and writes with respect to future read and write operations. There is no need for using read-modify-writes to achieve this order because the MEMBAR instruction can be used to order a write with respect to a succeeding read. The PowerPC model uses a single fence instruction called the SYNC instruction. It is similar to the MB instruction, but with a little exception that reads can occur out of program order even if a SYNC is placed between two reads to the same location. This model also differs from Alpha and RMO in terms of atomicity. It allows a write to be seen earlier than a read's completion. A combination of read modify write operations may be required to make an illusion of write atomicity.

RMO and PowerPC allow reordering of reads to the same location. These models violate sequential order in examples A and B. An additional relaxation allowed in these models is that memory operations following a read operation can be overlapped and reordered with respect to the read. Alpha and RMO allow a read to return the value of another processor's early write. From a programmer's perspective these models must maintain the illusion of write atomicity even though they allow the processor to read its own write early.

Transactional memory models

[edit]

Transactional memory model[7] is the combination of cache coherency and memory consistency models as a communication model for shared memory systems supported by software or hardware; a transactional memory model provides both memory consistency and cache coherency. A transaction is a sequence of operations executed by a process that transforms data from one consistent state to another. A transaction either commits when there is no conflict or aborts. In commits, all changes are visible to all other processes when a transaction is completed, while aborts discard all changes. Compared to relaxed consistency models, a transactional model is easier to use and can provide higher performance than a sequential consistency model.

Other consistency models

[edit]

Some other consistency models are as follows:

Several other consistency models have been conceived to express restrictions with respect to ordering or visibility of operations, or to deal with specific fault assumptions.[24]

Consistency and replication

[edit]

Tanenbaum et al., 2007[4] defines two main reasons for replicating; reliability and performance. Reliability can be achieved in a replicated file system by switching to another replica in the case of the current replica failure. The replication also protects data from being corrupted by providing multiple copies of data on different replicas. It also improves the performance by dividing the work. While replication can improve performance and reliability, it can cause consistency problems between multiple copies of data. The multiple copies are consistent if a read operation returns the same value from all copies and a write operation as a single atomic operation (transaction) updates all copies before any other operation takes place. Tanenbaum, Andrew, & Maarten Van Steen, 2007[4] refer to this type of consistency as tight consistency provided by synchronous replication. However, applying global synchronizations to keep all copies consistent is costly. One way to decrease the cost of global synchronization and improve the performance can be weakening the consistency restrictions.

Data-centric consistency models

[edit]

Tanenbaum et al., 2007[4] defines 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 among writes is difficult, some restrictions can be applied on the values that can be returned by a read operation. The goal of data-centric consistency models is to provide a consistent view on a data store where processes may carry out concurrent updates.

Consistent ordering of operations

[edit]

Some consistency models such as sequential and also causal consistency models deal with the order of operations on shared replicated data in order to provide consistency. In these models, all replicas must agree on a consistent global ordering of updates.

Grouping operations
[edit]

In grouping operation, accesses to the synchronization variables are sequentially consistent. A process is allowed to access a synchronization variable that all previous writes have been completed. In other words, accesses to synchronization variables are not permitted until all operations on the synchronization variables are completely performed.[4]

Client-centric consistency models

[edit]

In distributed systems, maintaining sequential consistency in order to control the concurrent operations is essential. In some special data stores without simultaneous updates, client-centric consistency models can deal with inconsistencies in a less costly way. The following models are some client-centric consistency models:[4]

Consistency protocols

[edit]

The implementation of a consistency model is defined by a consistency protocol. Tanenbaum et al., 2007[4] illustrates some consistency protocols for data-centric models.

Continuous consistency

[edit]

Continuous consistency introduced by Yu and Vahdat (2000).[25] In this model, the consistency semantics of an application is described by using conits in the application. Since the consistency requirements can differ based on application semantics, Yu and Vahdat (2000)[25] believe that a predefined uniform consistency model may not be an appropriate approach. The application should specify the consistency requirements that satisfy the application semantics. In this model, an application specifies each consistency requirement as a conit (abbreviation of consistency units). A conit can be a physical or logical consistency and is used to measure the consistency. Tanenbaum et al., 2007[4] describes the notion of a conit by giving an example.

There are three inconsistencies that can be tolerated by applications.

Deviation in numerical values
[25] Numerical deviation bounds the difference between the conit value and the relative value of the last update. A weight can be assigned to the writes which defines the importance of the writes in a specific application. The total weights of unseen writes for a conit can be defined as a numerical deviation in an application. There are two different types of numerical deviation; absolute and relative numerical deviation.
Deviation in ordering
[25] Ordering deviation is the discrepancy between the local order of writes in a replica and their relative ordering in the eventual final image.
Deviation in staleness between replicas
[25] Staleness deviation defines the validity of the oldest write by bounding the difference between the current time and the time of the oldest write on a conit not seen locally. Each server has a local queue of uncertain write that is required an actual order to be determined and applied on a conit. The maximal length of uncertain writes queue is the bound of ordering deviation. When the number of writes exceeds the limit, instead of accepting new submitted write, the server will attempt to commit uncertain writes by communicating with other servers based on the order that writes should be executed.

If all three deviation bounds are set to zero, the continuous consistency model is the strong consistency.

Primary-based protocols

[edit]
Primary backup protocol
Primary-backup protocol (local-write)

Primary-based protocols[4] can be considered as a class of consistency protocols that are simpler to implement. For instance, sequential ordering is a popular consistency model when consistent ordering of operations is considered. The sequential ordering can be determined as primary-based protocol. In these protocols, there is an associated primary for each data item in a data store to coordinate write operations on that data item.

Remote-write protocols
[edit]

In the simplest primary-based protocol that supports replication, also known as primary-backup protocol, write operations are forwarded to a single server and read operations can be performed locally.

Example: Tanenbaum et al., 2007[4] gives an example of a primary-backup protocol. The diagram of primary-backup protocol shows an example of this protocol. When a client requests a write, the write request is forwarded to a primary server. The primary server sends request to backups to perform the update. The server then receives the update acknowledgement from all backups and sends the acknowledgement of completion of writes to the client. Any client can read the last available update locally. The trade-off of this protocol is that a client who sends the update request might have to wait so long to get the acknowledgement in order to continue. This problem can be solved by performing the updates locally, and then asking other backups to perform their updates. The non-blocking primary-backup protocol does not guarantee the consistency of update on all backup servers. However, it improves the performance. In the primary-backup protocol, all processes will see the same order of write operations since this protocol orders all incoming writes based on a globally unique time. Blocking protocols guarantee that processes view the result of the last write operation.
Local-write protocols
[edit]

In primary-based local-write protocols,[4] primary copy moves between processes willing to perform an update. To update a data item, a process first moves it to its location. As a result, in this approach, successive write operations can be performed locally while each process can read their local copy of data items. After the primary finishes its update, the update is forwarded to other replicas and all perform the update locally. This non-blocking approach can lead to an improvement. The diagram of the local-write protocol depicts the local-write approach in primary-based protocols. A process requests a write operation in a data item x. The current server is considered as the new primary for a data item x. The write operation is performed and when the request is finished, the primary sends an update request to other backup servers. Each backup sends an acknowledgment to the primary after finishing the update operation.

Replicated-write protocols

[edit]

In replicated-write protocols,[4] unlike the primary-based protocol, all updates are carried out to all replicas.

Active replication
[edit]

In active replication,[4] there is a process associated with each replica to perform the write operation. In other words, updates are sent to each replica in the form of an operation in order to be executed. All updates need to be performed in the same order in all replicas. As a result, a totally-ordered multicast mechanism is required. There is a scalability issue in implementing such a multicasting mechanism in large distributed systems. There is another approach in which each operation is sent to a central coordinator (sequencer). The coordinator first assigns a sequence number to each operation and then forwards the operation to all replicas. Second approach cannot also solve the scalability problem.

Quorum-based protocols
[edit]

Voting can be another approach in replicated-write protocols. In this approach, a client requests and receives permission from multiple servers in order to read and write a replicated data. As an example, suppose in a distributed file system, a file is replicated on N servers. To update a file, a client must send a request to at least N/2 + 1 in order to make their agreement to perform an update. After the agreement, changes are applied on the file and a new version number is assigned to the updated file. Similarly, for reading replicated file, a client sends a request to N/2 + 1 servers in order to receive the associated version number from those servers. Read operation is completed if all received version numbers are the most recent version.[4]

Cache-coherence protocols
[edit]

In a replicated file system, a cache-coherence protocol[4] provides the cache consistency while caches are generally controlled by clients. In many approaches, cache consistency is provided by the underlying hardware. Some other approaches in middleware-based distributed systems apply software-based solutions to provide the cache consistency.

Cache consistency models can differ in their coherence detection strategies that define when inconsistencies occur. There are two approaches to detect the inconsistency; static and dynamic solutions. In the static solution, a compiler determines which variables can cause the cache inconsistency. So, the compiler enforces an instruction in order to avoid the inconsistency problem. In the dynamic solution, the server checks for inconsistencies at run time to control the consistency of the cached data that has changed after it was cached.

The coherence enforcement strategy is another cache-coherence protocol. It defines how to provide the consistency in caches by using the copies located on the server. One way to keep the data consistent is to never cache the shared data. A server can keep the data and apply some consistency protocol such as primary-based protocols to ensure the consistency of shared data. In this solution, only private data can be cached by clients. In the case that shared data is cached, there are two approaches in order to enforce the cache coherence.

In the first approach, when a shared data is updated, the server forwards invalidation to all caches. In the second approach, an update is propagated. Most caching systems apply these two approaches or dynamically choose between them.

See also

[edit]

References

[edit]

Further reading

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
A in defines the guarantees provided by a concurrent or distributed regarding the ordering and of operations on shared data across multiple processes or nodes, specifying which execution histories are permissible to ensure predictable behavior. These models establish a between programmers and the , wherein adherence to certain programming disciplines results in outcomes equivalent to some sequential execution order consistent with the program's specified dependencies. Consistency models are fundamental to the design and analysis of , multiprocessor systems, and distributed databases, where they balance correctness with performance trade-offs such as latency and availability. Stronger models, like —which requires operations to appear atomic and respect real-time ordering—and , introduced by in 1979 as an interleaving of process operations executed in sequence, provide robust guarantees but impose higher synchronization costs. Weaker models, such as (preserving cause-effect relationships without a ) and (ensuring replicas converge after sufficient time without further updates), enable greater scalability and fault tolerance in large-scale systems like databases, though they may allow temporary inconsistencies. The choice of consistency model depends on application requirements, with formal verification tools and testing frameworks like Jepsen used to validate system adherence. Over time, research has expanded to include session-based guarantees (e.g., read-your-writes) and hybrid approaches to address modern challenges in geo-replicated environments.

Fundamentals

Definition

In distributed and systems, a consistency model is a that specifies the allowable orderings of operations—such as reads and writes—on shared across multiple concurrent processes, ensuring predictable behavior by defining constraints on visibility and ordering without requiring all operations to be globally atomic. These models arise from the need to manage concurrency challenges, such as race conditions where the outcome of interleaved operations depends nondeterministically on their relative timing, by establishing partial orders that reconcile and global views of state. Consistency models differ from atomicity, which ensures that individual operations appear to occur instantaneously at a single point in time without interleaving, by instead focusing on the propagation and perception of operation effects across distributed replicas or processors. They also contrast with isolation in transactional systems, which prevents concurrent transactions from interfering with one another as if executed sequentially, whereas consistency models emphasize non-transactional and the rules for when updates become visible to observers. A basic illustration occurs in a single-writer/multi-reader , where one performs a write to shared data, and multiple other read it; the consistency model dictates the conditions under which readers will observe the updated value, potentially allowing temporary discrepancies in visibility until the write propagates according to the specified ordering rules. represents a strong example of such a model, requiring that all see operations in a single global consistent with each process's individual program order.

Historical Development

The development of consistency models originated in the 1970s amid challenges in early multiprocessor systems, particularly issues arising from caching and access in concurrent environments. introduced the concept of in his seminal 1979 paper, defining it as a model where the results of any execution appear to be the same as if the operations of all processors were executed in some sequential order consistent with each processor's program order. This formulation addressed the need for a formal guarantee of correctness in multiprocessor computers, providing a strong baseline for reasoning about parallel program behavior without requiring strict hardware synchronization at every memory access. During the 1980s and 1990s, researchers advanced weaker consistency models to improve performance in shared-memory multiprocessors by relaxing some ordering constraints while preserving essential correctness properties. James R. Goodman proposed processor consistency in 1989, which enforces program order for reads and writes from the same processor but allows out-of-order visibility of writes across processors, enabling more aggressive caching and pipelining. Building on this, Kourosh Gharachorloo, Daniel Lenoski, James Laudon, Phillip Gibbons, Anoop Gupta, and John Hennessy introduced release consistency in 1990, distinguishing between ordinary and synchronization operations (acquire/release) to further buffer writes and reduce communication overhead in scalable systems. The 2000s marked a shift toward even more relaxed models, driven by the proliferation of distributed systems and heterogeneous architectures, where strict consistency proved too costly for scalability. In distributed databases, Amazon's system popularized in 2007, allowing temporary inconsistencies with guarantees of convergence under normal conditions to prioritize availability and partition tolerance. Concurrently, hardware architectures adopted weaker models; for instance, formalized its relaxed model in the 2011 Architecture Reference Manual, permitting reordering of memory operations except those bounded by explicit barriers, to optimize for power-efficient mobile and embedded devices. By the and into the , consistency models have integrated deeply with modern hardware and cloud-native infrastructures, emphasizing tunable trade-offs for diverse workloads up to 2025. Intel's x86 architecture implements Total Store Order (TSO) as its default model, where stores from a processor are seen in order by others but loads may overtake stores, formalized in vendor documentation and analyzed in rigorous models. Similarly, AMD's AMD64 architecture adopts a comparable relaxed ordering, with extensions for primitives to support . In cloud-native environments, tunable consistency—allowing applications to select levels from strong to eventual—has become standard, influenced by systems like and enabling elastic scaling in architectures.

Key Terminology

In the context of consistency models, operation ordering refers to the constraints imposed on the sequence of accesses across multiple es or processors. Program order denotes the sequential arrangement of operations as defined within a single , ensuring that each perceives its own instructions in the intended sequence. A total order extends this to a global serialization, where all operations from every appear to execute in a single, unambiguous sequence as if issued by one at a time, as exemplified in strict consistency models. In contrast, a partial order permits certain relaxations, allowing operations—such as writes to independent locations—to be reordered or observed out of program order without violating the model's guarantees. Visibility and propagation describe how and when the effects of a write operation become to other processes. Visibility occurs when a write's updated value is accessible to subsequent reads by any process, often delayed by hardware mechanisms that must propagate changes across the system. Propagation ensures that this value is disseminated reliably, typically requiring acknowledgment from caches or memory. Synchronization points, such as explicit instructions in the program, serve as critical junctures where visibility is enforced, guaranteeing that prior writes are complete and visible before subsequent operations proceed. Linearizability and serializability are distinct correctness criteria for concurrent systems, both aiming to provide intuitive ordering but differing in their constraints. Linearizability imposes real-time ordering, ensuring that each operation appears to take effect instantaneously at a single point between its invocation and response, preserving the partial order of non-overlapping operations while allowing concurrency. Serializability, however, requires only that the overall execution be equivalent to some serial (non-concurrent) execution of the operations, without enforcing real-time constraints on individual operations' timing. Linearizability is thus a stricter form, often viewed as a special case of strict serializability for single-operation transactions. Key terms in consistency models include the following:
  • Buffer (write buffer): A hardware queue that temporarily holds write operations, enabling processors to continue execution without waiting for acknowledgment, which can lead to reordered observations if not managed.
  • Fences/barriers (synchronization primitives): Instructions that enforce ordering by preventing operations before the from being reordered after it, acting as safety mechanisms in relaxed models to restore necessary program order.
  • Happens-before relation: A partial ordering in multithreaded programs where, if action x happens-before action y, then x is visible to and ordered before y according to rules such as program order within a thread or events; this relation, formalized in the Memory Model (JSR-133, 2004), ensures predictable visibility without full .

Memory Consistency Models

Strict Consistency

Strict consistency represents the strongest form of memory consistency, requiring that all memory operations appear to occur instantaneously at unique points in global real time. Under this model, a read operation on a memory location must always return the value produced by the most recent write to that , where recency is determined by an absolute global time order. This equivalence holds as if the system operates with a single, atomic global memory visible to all processes without any delay or caching effects. The key properties of strict consistency include absolute time ordering of all shared memory accesses and the prohibition of any buffering, caching, or reordering of operations that could violate real-time visibility. Writes must propagate instantaneously across the system, ensuring that no observes an outdated value after a write has occurred in global time. This model demands perfect among all processors, making it theoretically ideal for maintaining a consistent view of but challenging to achieve in practice due to communication latencies in shared-memory multiprocessors. For example, consider a shared variable x initialized to 0. If process P1 executes a write x = 1 at global time t_1, then any subsequent read of x by process P2 at time t_2 > t_1 must return 1, irrespective of the processors' physical separation or network delays. This immediate visibility ensures no temporal anomalies in observed values. However, the stringent requirements of strict consistency impose significant performance limitations, as implementing instantaneous global propagation necessitates excessive synchronization overhead, such as frequent barriers or locks across all processors. As a result, it is rarely fully implemented in modern shared-memory systems, where weaker models like provide sufficient guarantees with better scalability. Formally, strict consistency requires that the set of all memory operations across processes forms a total order that is consistent with the real-time partial order, meaning non-overlapping operations respect their initiation and completion times in a linearizable manner. This linearizability condition ensures that each operation appears to take effect atomically at a single point between its invocation and response, preserving causality and order in real time.

Sequential Consistency

Sequential consistency is a memory consistency model introduced by Leslie Lamport in 1979, defined such that the result of any execution of a multiprocessor program is the same as if the operations of all processors were executed in some sequential order, with the operations of each individual processor appearing in the program's specified order within that global sequence. This model ensures that all memory accesses appear atomic to the programmer and that there exists a single, total order of all operations that respects the per-process program order. Key properties of sequential consistency include the preservation of program order for operations within each process, meaning that if one operation precedes another in a process's code, it will precede it in the global order. Additionally, the model establishes a global sequential order for all operations across processes, but this order is not tied to real-time constraints, allowing concurrent operations to be serialized in any valid interleaving without requiring instantaneous visibility. Sequential consistency is weaker than strict consistency, which demands that operations be ordered according to absolute real time. A representative example involves two processes communicating via shared flags to illustrate the model's guarantees. Process P1 executes flagX = 1 followed by flagY = 1, while Process P2 executes a loop checking while (flagY == 0); and then reads flagX. Under , if P2 exits the loop and observes flagY = 1, it must also observe flagX = 1, as the global order preserves P1's program order and ensures a consistent visible to all processes. This prevents anomalous outcomes, such as P2 seeing flagY = 1 but flagX = 0, which could occur under weaker models. In practice, can be achieved through mechanisms like barriers or locks that enforce ordering at key points, serializing operations to mimic a sequential . It forms the basis for the happens-before relationship in the Memory Model, where properly synchronized programs—free of data races—exhibit , ensuring that actions ordered by (e.g., volatile writes and reads) appear in a consistent global sequence. Despite its intuitive appeal, sequential consistency imposes significant performance costs in large-scale systems, as it prohibits common hardware optimizations such as write buffering, operation reordering, and overlapping memory accesses, which are essential for in multiprocessors with caches and pipelines. These restrictions limit parallelism and increase latency, making it challenging to implement efficiently in modern distributed or multicore architectures without compromising throughput.

Causal Consistency

Causal consistency is a memory consistency model in systems that ensures all processes observe causally related operations in the same order, while allowing independent operations to be reordered across processes. Specifically, if operation A happens-before operation B due to a causal dependency—such as one operation reading the result of the other or being in the same thread of execution—then every process sees A before B; however, operations without such dependencies may appear in varying orders to different processes. This model combines per-process , where operations within a single appear in program order, with a global causal order for dependent operations, making it weaker than , which requires a single for all operations across all processes. As a result, permits greater concurrency and performance by relaxing constraints on unrelated events, while still preserving intuitive notions of cause and effect in applications. It is stronger than weaker models like but avoids the overhead of full . A representative example is a distributed chat system where a user posts a (operation A), and another user replies to it (operation B, causally dependent on A via a read of A). Under , all users see the reply after the original message, but unrelated messages from other conversations can interleave in different orders for different observers, enhancing responsiveness without violating . Formally, causal consistency relies on the happens-before relation to identify dependencies, originally defined using logical clocks to capture potential in distributed systems. Implementations often employ Lamport clocks, which assign timestamps to events such that if A happens-before B, then the clock of A is less than that of B, enabling processes to track and enforce causal order during reads and writes. Vector clocks extend this by maintaining a vector of timestamps per process, providing a more precise partial order for detecting without assuming a . Causal consistency finds application in session-based applications, such as collaborative tools or user sessions in databases, where actions within a session (e.g., a sequence of reads and writes by a single client) must maintain causal dependencies, but concurrent sessions from different users can proceed independently for better . For instance, implements causal consistency at the session level to ensure ordered observations of dependent operations across distributed replicas.

Intermediate Consistency Models

Processor Consistency

Processor consistency, proposed by James R. Goodman in 1989, is an intermediate memory consistency model that provides a relaxation of sequential consistency to enable hardware optimizations like write buffering while preserving key ordering guarantees. In this model, all writes issued by a given processor are observed in program order by every processor in the system, ensuring that if multiple writes from the same processor are visible to another processor, they appear in the issuing processor's order. However, a processor may observe the results of its own writes immediately, before those writes are propagated to and visible by other processors, allowing for the use of store buffers to hide memory latency. This distinction arises from treating reads and writes separately in terms of buffering, where reads from the issuing processor can bypass the store buffer. The core properties of processor consistency include maintaining program order for reads and writes independently on each processor and enforcing a consistent per-processor write serialization across all observers. Specifically, it combines —ensuring single-writer-multiple-reader semantics per memory location—with a pipelined (PRAM) store ordering, where all processors agree on the relative order of stores from any one processor. Unlike stricter models, it does not require a global for all memory accesses, permitting reordering of reads relative to writes from other processors as long as intra-processor write order is upheld. These properties enable efficient implementations in multiprocessor systems by allowing delayed write propagation without compromising the perceived order of a single processor's operations. To illustrate, suppose processor P1 executes a write to variable A followed by a write to variable B. Under processor consistency, any other processor P2 that observes both writes will see the update to A before the update to B, respecting P1's program order. However, P2 might perform a read of A and obtain its old value if P1's write to A is still pending in P1's store buffer, while a subsequent read by P1 itself would return the new value from A. This example highlights how the model accommodates store buffering for performance, potentially leading to temporary inconsistencies in visibility across processors. Compared to , processor consistency is weaker because it serializes writes only on a per-processor basis rather than enforcing a single global interleaving of all operations from all processors, which can allow more flexible hardware designs at the cost of requiring programmers to handle potential reordering with explicit . Early implementations of processor consistency appeared in the V8 architecture via its Total Store Ordering (TSO) model, which defines similar semantics as the default for both uniprocessors and shared-memory multiprocessors, permitting write buffering while ensuring ordered visibility of per-processor stores.

Pipelined RAM Consistency

Pipelined RAM consistency, also known as PRAM or FIFO consistency, is a memory consistency model in which all processors observe the writes issued by any individual processor in the same order that those writes were performed by the issuing processor, irrespective of the memory locations involved. This model ensures that the sequence of writes from a single source is preserved globally, but the relative ordering of writes from different processors can vary across observers, allowing for interleaving in arbitrary ways. Unlike stricter models such as sequential consistency, PRAM permits optimizations like buffering and pipelining of memory operations to improve performance in multiprocessor systems, as long as the per-processor write order is maintained. The key properties of PRAM include constant-time reads from local caches and serialized broadcasts for writes, which enable scalability by reducing contention on shared memory accesses. It is weaker than processor consistency in that it does not enforce a global write serialization across all processors for operations to different addresses, allowing greater reordering for cross-processor and cross-location interactions while still providing per-processor ordering. This relaxation supports hardware mechanisms like cache coherence protocols, which ensure that updates to the same location propagate correctly but do not impose stricter global ordering. For instance, consider two processors P1 and P2: P1 performs a write to location x followed by a write to location y, while P2 performs a write to location x. Under PRAM, all processors will see P1's write to x before its write to y, but one processor might observe P2's write to x after P1's write to y, while another observes it before. Historically, PRAM was proposed in the late to address performance bottlenecks in shared-memory multiprocessors, particularly for vector processors where pipelined access patterns are common, by modeling memory as a scalable broadcast-based system without full . Limitations of PRAM arise in scenarios requiring causal relationships across processors, as it does not guarantee that causally related operations (e.g., a write followed by a read that enables another write) are observed in a consistent order globally, necessitating explicit primitives like barriers or locks for such dependencies.

Cache Consistency

Cache consistency, more precisely known as , is not a memory consistency model but a hardware-level mechanism in multiprocessor systems that supports such models by ensuring all processors observe a coherent view of locations across their private caches. It addresses the challenge posed by caching, where multiple copies of the same data may exist, by enforcing protocols that propagate updates or invalidations to maintain uniformity for individual locations. This is achieved through write-invalidate or write-update strategies, where a processor's write to a location either invalidates remote cache copies or updates them, preventing stale data reads. Common implementations rely on either snooping-based or directory-based approaches. In snooping protocols, caches monitor a shared interconnect (such as a bus) for memory transactions and respond accordingly to maintain coherence, as introduced in early designs for scalable multiprocessors. Directory-based protocols, in contrast, use a centralized or distributed directory to track the state and location of cached blocks, notifying relevant caches on modifications; this scales better for large systems without broadcast overhead. Both mechanisms uphold the single-writer-multiple-reader (SWMR) property, ensuring that only one cache holds a modifiable copy of a block at any time while allowing multiple read-only copies. A representative example involves a write operation: if processor P1 writes to memory location x, its cache controller issues an invalidation request, causing caches in other processors (e.g., P2) holding x to mark their copies as invalid; subsequent reads by P2 then retrieve the updated value from P1's cache or main via the interconnect. One widely adopted protocol is MESI (Modified, Exclusive, Shared, Invalid), employed in modern multicore processors like those from . In MESI, cache lines transition between states—Modified for a uniquely held dirty copy, Exclusive for a uniquely held clean copy, Shared for multiple clean copies, and Invalid for non-present data—reducing unnecessary traffic by distinguishing clean shared data from modified versions. These hardware cache coherence protocols form the foundational layer for higher-level memory consistency models, such as , by guaranteeing that shared data appears atomic and ordered across processors for individual locations. They approximate the idealized goal of strict consistency for cached accesses while optimizing performance in real systems.

Weak and Relaxed Ordering Models

Weak Ordering

Weak ordering is a memory consistency model in which memory operations can be reordered freely by the and hardware, except at explicit points such as locks or barriers, ensuring that the system appears sequentially consistent only to programs that adhere to specified constraints. This model classifies memory accesses into operations, which may be reordered relative to other operations, and operations, which establish ordering boundaries and prevent reordering across them. The primary property of weak ordering is its provision of high performance through aggressive optimizations, as it allows processors to execute non-synchronized accesses out of program order, such as delaying writes in buffers or permitting reads to bypass pending writes, thereby maximizing hardware flexibility while requiring programmers to insert primitives like fences to enforce necessary order. For instance, in a without , a write to one variable might be delayed in a write buffer while subsequent reads or writes to unrelated variables proceed immediately, but upon reaching a point, all buffered operations are drained to ensure visibility to other processors. In the taxonomy of consistency models, is positioned as weaker than processor consistency, which maintains order for writes to different locations but still imposes more restrictions on read-write interleaving; this relative weakness enables broader reordering opportunities and serves as a foundational basis for further relaxed models like release consistency. Implementations of are found in architectures such as ARMv8-A, where accesses lacking dependencies can be issued or observed out of order unless barriers are explicitly used to impose .

Release Consistency

Release consistency is a memory consistency model that relaxes the ordering of ordinary accesses while using operations—specifically acquires and releases—to control the visibility and ordering of shared data updates. In this model, ordinary reads and writes to shared variables are not required to be ordered with respect to each other across processors unless constrained by synchronization points; however, an acquire operation ensures that the processor sees all writes that occurred before a corresponding on another processor, and a release ensures that subsequent acquires on other processors will see the writes performed before that release. This approach extends by explicitly distinguishing between synchronization accesses (acquires and releases) and ordinary accesses, allowing greater flexibility in hardware implementations while maintaining programmer control over critical sections. The model, introduced as an improvement over weak consistency, permits processors to buffer and reorder ordinary accesses freely, as long as synchronization points enforce the necessary ordering; for instance, writes within a need not propagate immediately but are guaranteed to be visible after the . Release consistency supports lazy mechanisms, where the propagation of updates from a processor's writes can be delayed until a operation, reducing inter-processor communication traffic compared to stricter models like , which require immediate visibility of all writes. This lazy propagation minimizes cache invalidations and coherence overhead, enabling better scalability in shared-memory multiprocessors. Release consistency has two main variants: RCsc (release consistency with sequential consistency for synchronization operations) and RCpc (release consistency with processor consistency for synchronization operations). RCsc requires that all acquire, release, and other special synchronization operations appear sequentially consistent across processors, meaning they are totally ordered and respect program order on each processor. In contrast, RCpc, which is more commonly implemented due to its relaxed nature, enforces only processor consistency among special operations, allowing reordering of special writes before special reads from different processors while still maintaining program order for acquires before ordinary accesses and ordinary accesses before releases. RCpc further permits ordinary reads to return values from writes that have not yet been released, providing additional optimization opportunities without violating the core visibility guarantees. A representative example of release consistency in action involves a shared lock protecting a critical section: a processor P1 performs writes to shared variables within the section after acquiring the lock, then releases the lock, making those writes visible to processor P2 only after P2 acquires the same lock, ensuring that P2 sees a consistent view of the data without requiring global ordering of all operations. This structured use of acquire and release points avoids the need for strict consistency on non-synchronized accesses, reducing latency in lock-unlock patterns common in parallel programs. The formal rules defining release consistency, particularly RCpc, are as follows:
  • R1 (Acquire rule): Before an ordinary read or write access is allowed to perform, all previous accesses on the same processor must have completed successfully.
  • R2 (Release rule): Before a release access is allowed to perform, all previous ordinary read and write accesses on the same processor must have completed.
  • R3 (Special ordering): and release accesses (special accesses) obey processor consistency, meaning writes to variables are seen in program order by other processors, but reads of variables may see stale values unless ordered by prior acquires.
  • R4 (Visibility rule): A successful guarantees that all writes performed before the corresponding release on another processor are visible to reads following the acquire, though ordinary accesses between points remain unordered.
These rules ensure that provides a barrier for propagation without imposing unnecessary global .

Entry Consistency

Entry consistency is a consistency model designed for (DSM) systems, where shared becomes consistent at a processor only upon acquiring a object, such as a lock, that explicitly guards the relevant objects. This model requires programmers to associate specific variables with shared items, ensuring that updates to those items are propagated and visible exclusively to subsequent holders of the same object. Upon unlocking or releasing the object, any changes made under its protection may invalidate cached copies elsewhere, but consistency is not enforced for unguarded . Key properties of entry consistency include the reduction of unnecessary invalidations and data transfers, as updates are tied directly to synchronization events rather than broadcast broadly. It employs ownership tracking mechanisms to manage exclusive (for writes) or shared (for reads) access modes, allowing systems to prefetch or transfer only the pertinent data during operations. For instance, if a lock LL protects a shared variable xx, a processor acquiring LL will see all prior updates to xx made under LL, but changes to unrelated variables remain unaffected unless guarded by the same lock. This fine-grained approach minimizes communication overhead in DSM environments. Entry consistency offers advantages in scalability for shared systems by leveraging common patterns to cluster related data transfers, thereby reducing network traffic and cache misses compared to coarser models. In evaluations on DSM prototypes like Midway, it demonstrated significantly fewer messages— for example, 24 versus 1,802 in a benchmark with two processors—leading to improved performance without requiring hardware support for stronger guarantees. Relative to release consistency, a coarser variant, entry consistency provides stronger guarantees for data protected by the same lock, as visibility is enforced precisely at acquisition for associated objects, while remaining weaker for non-synchronized accesses.

Platform-Specific Relaxed Models

Relaxed Write-to-Read Ordering

Relaxed write-to-read ordering is a class of memory consistency models that permit a read operation to bypass a preceding write from the same processor, allowing the read to potentially observe stale from before the write is visible in , while preserving the program order for all write-to-write and read-to-read operations across processors. This relaxation stems from implementations where writes are buffered locally before committing to the shared memory system, enabling reads to access main directly without waiting for the buffer to drain. A key property of these models is their use of safety nets, such as serialization instructions or fences, to enforce ordering when needed for synchronization; for instance, Total Store Ordering (TSO) relies on read-modify-write operations to ensure correctness in critical sections. They were prevalent in early relaxed architectures to balance performance gains from reordering with sufficient guarantees for programmability. Partial Store Order (PSO), an extension common in SPARC systems, maintains these write-to-read relaxations but introduces additional flexibility in write completion order across different locations, using explicit barriers like STBAR to restore total store ordering when required. Consider a processor executing the sequence: read from location A (r1), followed by write to A (w1). Under relaxed write-to-read ordering, r1 may return the pre-existing value in A rather than the value intended by w1, if the write remains in the processor's store buffer. This behavior contrasts with stricter models like , where such reordering is forbidden. In the of consistency models by Adve and Gharachorloo, relaxed write-to-read ordering occupies an intermediate position, stricter than —which further relaxes read-to-read and read-to-write constraints—but weaker than processor consistency, as it allows intra-processor write-to-read reordering. Implementations approximating this model include the x86 architecture's TSO, where loads may pass stores to different addresses, but stores maintain a and are not reordered with subsequent loads.

Alpha and PowerPC Models

The DEC Alpha architecture, introduced in the 1990s by Digital Equipment Corporation, employed a highly relaxed memory consistency model that permitted extensive reordering of memory operations to maximize performance in multiprocessor systems. Under this model, all types of memory accesses—loads and stores—could be reordered freely with respect to one another, including load-to-load, load-to-store, store-to-load, and store-to-store operations, except across explicit memory barriers. This full relaxation applied to operations on different memory locations, while the model preserved dependencies within a single processor and ensured write atomicity, meaning stores appeared atomic to other processors. To enforce ordering when necessary, programmers relied on two fence instructions: the memory barrier (MB), which serialized all prior and subsequent memory operations, and the write memory barrier (WMB), which ordered writes but allowed loads to pass. The Alpha model's extreme flexibility enabled aggressive hardware optimizations, such as and non-blocking caches, but it violated , potentially leading to counterintuitive behaviors in concurrent programs without barriers. For instance, a processor might observe a subsequent load completing before a prior store to a different becomes globally visible, requiring explicit for correct shared-memory programming. This approach influenced subsequent relaxed models by demonstrating the trade-offs between performance and programmability, with the architecture's reference manual specifying these rules to guide and hardware implementations. The PowerPC architecture, developed by , , and Apple in the early 1990s, adopted a similar relaxed (RMO) model, allowing free reordering of read-read, read-write, and write-read operations across different addresses to support high-performance pipelining and caching. In this model, memory operations lack inherent global ordering unless constrained by synchronization primitives, enabling stores to be buffered and loads to bypass prior writes, but preserving intra-processor data and address dependencies. Key properties include support for weak consistency, where sequential appearance is only guaranteed within a thread or across processors via explicit barriers, promoting optimizations like while requiring careful fence usage for coherence. PowerPC's RMO emphasizes programmer responsibility through instructions like lwsync (lightweight ), which enforces ordering of prior stores before subsequent loads and stores within a thread but permits store-to-load reordering, and sync (full ), which serializes all memory accesses globally. For example, in a producer-consumer , a write to variable w1 followed by a read from a different variable r2 may result in r2 observing stale data before w1 is visible to other processors, unless an lwsync intervenes to establish release-acquire semantics. This model's high optimization potential is evident in its use for embedded and server applications, where it balances speed and . In version 3.1, released in 2020 with revisions up to 3.1C as of 2024 and still current as of 2025, new instructions enhance support for systems within the existing RMO model, including persistent variants like phwsync (persistent heavyweight sync) and plwsync (persistent lightweight sync) for storage ordering, along with cache management instructions such as dcbstps and dcbfps. These updates maintain and address evolving hardware needs, such as better support for and error handling in large-scale processors, without altering core reordering freedoms.

Client-Centric and Session Guarantees

Client-centric consistency models provide guarantees tailored to individual client sessions rather than global system-wide ordering, enabling scalability in distributed and replicated systems. These include session guarantees, which collectively ensure intuitive behavior within a client's interaction context. The four primary session guarantees, as defined in foundational work on weakly consistent replicated data, are monotonic reads, read-your-writes, writes-follow-reads, and monotonic writes.

Monotonic Read Consistency

Monotonic read consistency is a client-centric in distributed systems that ensures if a reads a value corresponding to a particular write, any subsequent reads by the same on the same data item will return that value or a more recent one, preventing the observation of older versions after a newer one has been seen. This property maintains a non-decreasing sequence of observed writes within a session, making the appear progressively more up-to-date from the client's perspective. Key properties include its focus as a per-process assurance, independent of other clients' operations, which avoids the overhead of global while still providing intuitive behavior for session-based interactions. It restricts the selection of servers for reads to those whose state includes at least the writes seen previously, often implemented using version vectors to track and compare write sets efficiently. For example, consider a querying a shared variable x initialized to 0; if it first reads x = 1 (reflecting a write W1), a later read must return 1 or a value from a write after W1, but never 0 again. In practical scenarios, such as an appointment calendar application, this prevents a scheduled meeting from disappearing after being viewed, as subsequent reads would not revert to an earlier server state lacking that update. This guarantee forms a core component of session consistency models in replicated systems like , a 1990s mobile computing platform designed for weakly consistent data sharing among disconnected replicas. Unlike , which enforces ordering across all related operations globally, monotonic read consistency is weaker and applies only within a single process's session, avoiding inter-client dependencies. It complements related session guarantees, such as read-your-writes consistency, by addressing read-read ordering rather than write-read interactions.

Read-Your-Writes Consistency

Read-your-writes consistency, also known as read-my-writes, is a client-centric guarantee in distributed systems that ensures a observes the effects of its own write operations in subsequent reads of the same item. Specifically, if a process executes a write WW on data item xx, followed by a read RR on xx, then RR must return the value written by WW or a value from a later write. This model applies per-session or per-process, restricting guarantees to operations within the same client context. The primary property of read-your-writes consistency is to prevent a client from encountering stale data resulting from its own updates, thereby enhancing in scenarios involving intermittent connectivity or replicated data stores. It is weaker than models, as it does not synchronize views across multiple clients, but it is stronger than pure by enforcing visibility of self-generated changes. This guarantee is foundational in systems like replicated storage architecture, where it layers atop read-any/write-any replication to maintain session-specific predictability without requiring global coordination. A practical example occurs in web applications, such as platforms, where a user posts a and immediately refreshes the feed; the post should appear without delay, avoiding the frustration of seeing an outdated view. In analogous terms, consider a scorekeeper in a game updating the score to 2-5; their next query must reflect at least this score or a later one, ensuring personal actions are consistently visible. To implement read-your-writes consistency, systems commonly use session tokens that capture the state of committed writes, allowing subsequent reads to be routed to replicas that include those updates, as seen in Azure Cosmos DB's session consistency level. Alternatively, sticky routing or session affinity directs all client operations to the same replica, naturally providing the guarantee by avoiding cross-replica inconsistencies for that session, though it may limit load balancing. A key limitation is that read-your-writes offers no assurances for other clients or processes, which may continue to see pre-write values until replication propagates the changes.

Writes-Follow-Reads Consistency

Writes-follow-reads consistency, also known as session causality, is a client-centric guarantee in distributed systems that ensures a write operation by a process takes effect based on the value most recently read by that same process. Specifically, if a process reads a value vv produced by write w1w_1 and later issues write w2w_2, then w2w_2 must be ordered after w1w_1 in the system's arbitration order, preventing w2w_2 from propagating on a stale version of the data. This property maintains dependency order for writes conditioned on prior reads within a session, making it particularly useful for incremental updates where subsequent operations build directly on observed data. It strengthens session guarantees by enforcing between reads and dependent writes, ensuring that the effects of a read are respected before related writes are applied globally. In conjunction with read-your-writes consistency, it forms a paired guarantee that preserves logical progression in client interactions. A representative example involves a reading the value of variable x=5x = 5 and then writing y=x+1y = x + 1; writes-follow-reads ensures y=6y = 6 by basing the write on the read value, rather than a potentially stale earlier version of xx. This avoids anomalies where updates appear inconsistent with the client's view, such as seeing replies to a post without first observing the original post itself. In practice, writes-follow-reads is applied in collaborative editing systems, where users' updates must depend on the document state they have viewed to maintain coherent incremental changes across replicas.

Monotonic Writes Consistency

Monotonic writes consistency is a client-centric guarantee in distributed systems that ensures writes issued by a process within a session are applied in order and visible to other clients only after all preceding session writes are incorporated. Specifically, if a process issues write W1W_1 followed by W2W_2 on the same data item, then for any replica, if W2W_2 is visible, W1W_1 must also be present and ordered before W2W_2. This property prevents later writes from a session from overtaking or being applied without earlier ones, maintaining the intended sequence of updates from the client's perspective and ensuring global visibility respects session order. It applies across clients, as it affects how writes propagate to other replicas, but remains scoped to the issuing session's dependencies. Implementation often involves tracking the session's write set and conditioning the application of new writes on the inclusion of prior ones, using mechanisms like write identifiers or version vectors. For example, in a with replicated files, a user saving version N followed by version N+1 ensures that N+1 replaces N at all servers without N overwriting N+1 later, avoiding version conflicts. This guarantee is integral to session consistency models like those in and modern systems such as , where it complements the other session guarantees by addressing write-write ordering within a session. Unlike global , it avoids full synchronization but enforces per-session monotonicity to support predictable update propagation in weakly connected environments.

Transactional and Local Models

Transactional Memory Consistency

Transactional memory consistency refers to the guarantees provided by transactional memory systems, where blocks of code executed as transactions appear atomic to concurrent executions, ensuring that committed transactions maintain a consistent view of memory as if executed serially. In these systems, transactions provide isolation, meaning reads within a transaction see a consistent snapshot of memory, and atomicity ensures that either all writes from a transaction are visible or none are. Consistency is typically achieved through serializability, where the effects of committed transactions can be ordered into a sequential execution that respects the real-time order of non-overlapping transactions. Implementations of transactional memory include optimistic software transactional memory (STM), which uses versioning and validation to detect conflicts, and hardware transactional memory (HTM), which speculatively executes transactions using hardware buffers for reads and writes. In both cases, conflict resolution occurs through abortion and rollback of overlapping transactions, preventing interference and maintaining isolation; for instance, if two transactions attempt to write to the same location, one aborts to resolve the contention. This optimistic approach contrasts with pessimistic locking but aligns with entry consistency as a lock-based analog by scoping updates to critical sections. A representative example involves two transactions: T1 reads variable x and writes to y, while T2 reads y and writes to x. Under transactional consistency, if T1 and T2 overlap, one must abort, ensuring that the committed execution appears as if T1 completed entirely before or after T2, preserving serializability without partial visibility of updates. Key correctness models for transactional memory include strong serializability, which linearizes all committed transactions, and opacity, a weaker but progress-oriented condition that additionally ensures no transaction reads values from aborted transactions while maintaining real-time ordering for committed ones. Opacity provides a balance between correctness and liveness, preventing livelock in high-contention scenarios by allowing transactions to read from committed states only. Modern hardware support includes Intel's (TSX), introduced in 2013 with Haswell processors but disabled by default on most CPUs since 2021 microcode updates due to security vulnerabilities (remaining available on select server processors), which implements restricted transactional via RTM instructions for optimistic execution, ensuring linearizable commits on success and full rollback on conflicts like capacity overflows or data contention. Similarly, ARM's Transactional Memory Extension (TME), part of the Armv9-A architecture introduced in 2021 and refined in subsequent versions, adds instructions like TSTART and TCOMMIT to enable hardware-managed transactions with isolation guarantees, aborting on memory conflicts to uphold atomicity and consistency.

Local and General Consistency

Local consistency refers to a weak model in distributed systems where each individual node or maintains for its own operations, typically ensuring that a observes its writes in the order they were issued, while providing no guarantees about the ordering or visibility of operations across different nodes. This per-node sequential behavior allows local computations to proceed efficiently without waiting for global , making it suitable for systems prioritizing low-latency access at . For instance, in a multi-node setup, Node A might execute its writes sequentially and immediately see the results locally, but Node B could observe those updates out of order relative to its own or in a delayed manner, potentially leading to temporary inconsistencies system-wide. The properties of emphasize over strict coordination, as nodes can continue operating independently during network partitions or high contention, with handled asynchronously if needed. It balances performance in large-scale environments by avoiding the overhead of stronger models, though it risks divergent views of until occurs. This model serves as a foundational weak , extending beyond traditional contexts to scenarios like , where local autonomy supports real-time processing without impeding overall system scalability. General consistency provides minimal system-wide assurances in distributed systems, ensuring that all replicas of a item become identical at some point after writes complete (equivalent to ), but without enforcing atomicity, ordering, or immediate visibility for reads and writes. Unlike implementations like bounded staleness—which guarantee that any read reflects a version no older than a configurable threshold, such as a fixed number of preceding writes (e.g., up to operations) or a time interval (e.g., T seconds)—general consistency offers no such bounds on convergence time. For example, in a globally replicated database, replicas will eventually converge if no further updates occur, but reads may see arbitrary stale versions in the interim, providing without predictable freshness. This model prioritizes and in partitioned networks, as nodes can serve reads from local copies, deferring full convergence. Unlike transactional consistency, which enforces isolation and atomicity within defined blocks, general consistency forgoes such mechanisms to enable broader applicability in non-transactional data stores and weak replication schemes. By focusing on eventual convergence rather than bounded divergence, it extends weak consistency principles to diverse contexts like , supporting scalable operations where occasional staleness is tolerable.

Distributed System Consistency

Eventual Consistency

Eventual consistency is a weak consistency model in distributed systems where replicas of data may temporarily differ, but if no new updates are made, all replicas will eventually converge to the same value, without any specified bounds on the time required for this convergence. This model arises from the need to balance and partition tolerance in large-scale systems, as per the , allowing updates to proceed even during network partitions. Key properties of eventual consistency include , as systems can accept writes and reads without waiting for global agreement, and tolerance for temporary inconsistencies that resolve over time. often relies on simple strategies like last-writer-wins, where the most recent update, based on timestamps or vector clocks, overwrites others, though this can lead to if concurrent writes occur. A classic example is DNS propagation: when a domain's is updated, caching resolvers worldwide may return outdated records briefly due to varying TTL values and propagation delays, but all eventually reflect the new mapping once caches expire. Variants of eventual consistency provide targeted strengthening while retaining its core liveness property. Strong eventual consistency ensures convergence to a single value without conflicts, often by integrating guarantees like read-your-writes to prevent clients from observing stale data from their own sessions. Causal+ adds preservation of causal dependencies—such as ensuring a reply to a is seen after the original—while still guaranteeing eventual agreement on non-causally related updates. These variants can optionally incorporate client-centric guarantees for better . In practice, eventual consistency powers scalable databases like , which uses it to distribute data across commodity hardware while maintaining through tunable replication. However, critiques have noted challenges, particularly in handling update conflicts during periods of disconnection, as seen in early replicated storage systems where manual resolution was often required.

Data-Centric Consistency Models

Data-centric consistency models focus on providing global guarantees about the state and evolution of shared in replicated distributed systems, ensuring that all clients observe operations on the in a consistent manner regardless of their individual perspectives. These models emphasize server-side enforcement of operation ordering across replicas, treating the as a single logical entity where concurrent updates are resolved to maintain a coherent view for all participants. Unlike weaker approaches, data-centric models prioritize the of the data's history over per-client optimizations, making them suitable for applications requiring reliable global synchronization, such as financial systems. A fundamental property of data-centric consistency models is the enforcement of a total or partial order on operations, often through mechanisms like atomic broadcasts or timestamping, which ensure that all replicas apply updates in the same sequence. For instance, linearizability, one of the strongest such models, requires that each operation appears to occur instantaneously at a single point in real time between its invocation and response, preserving both a total order and real-time precedence among non-overlapping operations. This extends the notion of atomicity from single machines to distributed environments, allowing developers to reason about the system as if it were sequentially consistent with added temporal constraints. Sequential consistency, a related model, guarantees that the outcome of all operations matches some interleaving that respects the program order at each process, but without enforcing real-time ordering, thus providing a linearizable view of history without clock synchronization overheads. Weaker data-centric models, such as , preserve only the causal dependencies between operations—ensuring that if one operation causes another (e.g., a write followed by a read that propagates it), all processes see them in that order—while allowing concurrent operations to be reordered differently across replicas. PRAM (Pipelined ) consistency further relaxes this by guaranteeing that writes to the same data item from a single writer are observed in issuance order by all readers, akin to a FIFO queue per variable, but permitting arbitrary interleaving from different writers. These properties are typically implemented using logs or timestamps to serialize updates globally, ensuring, for example, that a write to variable xx is visible to all clients in the uniform sequence relative to other writes on xx. Data-centric models build upon shared memory consistency concepts by adapting sequential consistency for distributed replication, where physical separation of replicas necessitates protocols to simulate a unified memory view across networks. To balance strictness with performance in wide-area systems, tunable variants allow applications to specify staleness bounds, such as limiting the maximum number of intervening writes a read can miss, as explored in early work on application-controlled replication. Eventual consistency provides a weaker alternative focused on convergence without ordering guarantees, contrasting with the structured convergence demanded by data-centric models. For example, Google's Spanner database implements linearizability using synchronized clocks for global transactions.

Client-Centric Consistency Models

Client-centric consistency models provide tailored consistency guarantees from the perspective of an individual client or session in a distributed , ensuring that a client's sequence of operations appears consistent relative to its own prior actions without enforcing a global order across all clients. These models emerged as a response to the limitations of global consistency approaches in highly available, replicated data stores, where strict would compromise and . By focusing on per-client views, they allow each client to maintain a monotonic progression of reads and writes within their session, such as ensuring that once a value is read, subsequent reads by the same client do not return older values (monotonic reads). Key properties of client-centric models include the combination of session-specific guarantees like read-your-writes (where a client always sees its own recent writes), monotonic writes (where writes are applied in the order issued by the client), and writes-follow-reads (where a client's writes are ordered after its reads). These properties collectively ensure a coherent client experience while permitting weaker global consistency, such as eventual consistency across the system, to prioritize availability during partitions or high loads. Unlike data-centric models, client-centric approaches do not require uniform visibility for all participants, enabling optimizations like client-side caching or asynchronous replication that reduce latency without affecting other users' views. A representative example is an shopping cart, where a user adding an item to their cart expects to see that update in subsequent views (read-your-writes) and avoids seeing stale or overwritten states from their own actions (monotonic reads), even if other users experience delayed propagation of the same change due to . This per-client tailoring prevents anomalies like a user losing items from their cart mid-session, enhancing without imposing global costs. In web-scale systems, client-centric models are widely adopted to support high-throughput applications, such as feeds or collaborative editing tools, where session guarantees ensure intuitive interactions for millions of concurrent users. Post-2020 trends in architectures have emphasized hybrid variants, blending client-centric guarantees with eventual or to handle inter-service data flows; for instance, distributed caching systems allow per-request specification of consistency levels, combining monotonic session views for user-facing operations with relaxed propagation for backend analytics. This hybrid approach mitigates consistency challenges in environments, improving resilience in cloud-native deployments.

Replication and Protocols

Consistent Ordering Protocols

Consistent ordering protocols are mechanisms employed in replicated distributed systems to guarantee that operations or messages are delivered and executed in the same total order across all replicas, thereby enabling strong consistency models such as sequential consistency, and supporting linearizability when augmented with real-time ordering. These protocols address the challenge of coordinating replicas without a shared clock or memory, ensuring that if one replica processes operation A before B, all others observe the same sequence. A foundational primitive in this domain is total order broadcast (also known as atomic broadcast), where messages are delivered reliably and in a consistent sequence to all recipients, preventing conflicts in state replication. Key properties of these protocols include agreement on the order via mechanisms such as sequence numbering or consensus algorithms. For instance, protocols often use a sequencer to assign unique identifiers to messages, or leverage consensus protocols like to achieve distributed agreement on the ordering without relying on a single point of coordination. In -based approaches, proposers, acceptors, and learners collaborate in phases to select and commit a value (e.g., a message order), tolerating failures as long as a of nodes remain operational. This ensures (all agree on one order) and liveness (progress under partial synchrony), critical for maintaining consistency in asynchronous environments. A classic example illustrating ordering principles is Lamport's bakery algorithm, originally designed for in shared-memory systems but extendable to distributed settings for ordering process requests. In the algorithm, each process picks a "ticket" number before attempting access and waits for lower-numbered tickets to complete, establishing a based on ticket values and process IDs to resolve ties. This approach has been generalized to build distributed state machines, where ticket-like sequencing ensures serialized execution across nodes. Consistent ordering protocols vary in design, particularly between centralized and distributed types. Centralized sequencers designate a single node to assign sequence numbers to incoming messages before them, simplifying implementation and reducing coordination overhead. In contrast, distributed protocols, such as those in Viewstamped Replication, achieve ordering through view changes and agreement among replicas, avoiding a permanent central by electing primaries dynamically. Viewstamped Replication ensures by committing operations only after a acknowledges them in , handling crashes via reconfiguration. Performance trade-offs in these protocols balance latency, throughput, and . Centralized sequencers typically incur lower latency—often one round-trip for ordering—but introduce a , potentially halting the system if the sequencer crashes. Distributed protocols like -based ordering or Viewstamped Replication offer greater resilience, sustaining operation with up to f failures in 2f+1 replicas, but at the expense of higher latency from multiple communication rounds (e.g., 2-3 for Paxos basic phase) and reduced throughput under contention. These trade-offs are evident in evaluations where centralized approaches achieve higher message rates in low-failure scenarios, while distributed ones maintain consistency during partitions. Such protocols ultimately support data-centric consistency models by enforcing uniform update application across replicas.

Primary-Based Protocols

Primary-based protocols, also referred to as primary-copy or primary-backup replication, designate a single primary replica as the authoritative coordinator for all write operations on a replicated data item, with backup replicas maintaining passive copies. All client write requests are directed to the primary, which processes the update and subsequently propagates it to the backups to ensure replication. This centralization simplifies the enforcement of consistency models by confining write serialization to one site, avoiding the complexities of concurrent updates across multiple replicas. Key properties of primary-based protocols include strict consistency at the primary site, where updates are immediately reflected, and the ability to support models like through ordered propagation. Reads may be served from any for performance, but to uphold consistency, they are typically routed to the primary or validated against it using timestamps or version numbers, preventing stale data access. is facilitated by electing a new primary from the backups upon detecting the current one's failure, preserving system availability without if a of replicas remain operational. These protocols integrate with consistent ordering mechanisms to guarantee that propagated updates respect the global of operations. A representative example is the (GFS), where the master server functions as the primary for all metadata mutations, such as file namespace changes, and propagates these updates to backup masters for redundancy. For large file data stored in chunks, the master grants short-term leases to designate one chunkserver as the primary replica for coordinating writes among its backups, ensuring atomic appends and consistent replication across typically three copies. This design achieves high throughput for read-heavy workloads while maintaining through master replication and chunk lease mechanisms. Variants of primary-based protocols differ in update strategies and read handling. Eager synchronously forwards updates to backups (often a ) before acknowledging the write, providing but increasing latency due to coordination overhead. In contrast, lazy defers updates asynchronously, enhancing and at the risk of brief inconsistencies during read operations from backups. For reads, active variants allow distribution to backups after primary validation, balancing load while preserving ordering, whereas passive approaches restrict reads to the primary for simplicity. Fault tolerance in primary-based protocols relies on heartbeat mechanisms to monitor the primary's liveness, with backups collectively detecting failures within a timeout period. Upon failure, an election algorithm selects a new primary, typically requiring majority agreement to ensure the chosen replica has the most up-to-date state. The Raft consensus protocol exemplifies a modern implementation, using leader election with randomized timeouts and replicated logs to safely transfer the primary role, tolerating up to (n-1)/2 failures in a system of n replicas while maintaining linearizability. This approach has been widely adopted in systems like etcd and Consul for its clarity and efficiency in enforcing consistency.

Replicated-Write Protocols

Replicated-write protocols enable concurrent write operations across multiple replicas in distributed systems by disseminating updates to all or a of replicas and using -based mechanisms to achieve agreement on the write's success. A write is typically acknowledged only after a sufficient number of replicas (a write , W) confirm it, while reads require a read (R) such that W + R > N, where N is the total number of replicas; this intersection ensures that reads reflect recent writes under tunable parameters, allowing trade-offs between consistency, , and . These protocols support multi-writer concurrency, distinguishing them from leader-serialized approaches. Such protocols balance with consistency guarantees by leveraging fault-tolerant consensus algorithms like or Atomic Broadcast (ZAB), which tolerate failures up to a minority of replicas while propagating writes synchronously or asynchronously. Conflicts arising from concurrent writes are often resolved through versioning schemes, where replicas compare vector clocks or timestamps to determine the latest update, merging or discarding divergent versions as needed. This design promotes availability during partitions, as writes can proceed if a is reachable, but may require anti-entropy mechanisms like read repair or hinted handoffs for full propagation. A prominent example is Amazon's , which uses replicated writes with configurable quorums (default W=2, R=2 for N=3) to provide , ensuring for key-value stores by allowing reads to return potentially stale data that converges over time through background and Merkle trees for reconciliation. In contrast, Google Spanner employs replicated writes coordinated via groups, augmented by the TrueTime API—which bounds clock uncertainty using GPS and atomic clocks—to assign timestamps that enforce linearizable (external) consistency, guaranteeing that transactions appear to take effect instantaneously at some point between invocation and response. Variants of replicated-write protocols include chain replication, which arranges replicas in a linear chain to enforce on writes: the head replica accepts and forwards updates sequentially to the tail, which confirms to the client, achieving with high throughput and via dynamic reconfiguration. Pessimistic variants employ upfront locking or two-phase commit to prevent conflicts, ensuring strict serializability at the cost of latency, while optimistic variants allow concurrent writes and detect conflicts post-facto via validation, rolling back invalid ones to favor liveness in high-contention scenarios. Key challenges in replicated-write protocols revolve around efficient , particularly for non-commutative operations where concurrent updates may produce ambiguous states; Conflict-free Replicated Data Types (CRDTs) mitigate this by designing structures with monotonic operations and merge functions that guarantee convergence to a unique value regardless of update order, as formalized for commutative replicated data types in , enabling optimistic replication without coordination overhead.

References

Add your contribution
Related Hubs
User Avatar
No comments yet.