Consistency models or consistency levels provide developers with a way to choose between better performance and high availability.
The consistency models available in Cosmos DB are:
- Strong: It fetches the most recent version of the data every time a read operation occurs. The cost of reading operation is higher compared to other consistency models in this model.
- Bounded Staleness: It allows setting a time lag between the write and the read operation. It is suitable for scenarios with equal priority for availability and consistency.
- Session: It is the default and most popular consistency level in Cosmos DB based on regions. A user will see the latest data after accessing the same region where the write was performed. Among all consistency levels, it offers the lowest latency reads and writes.
- Consistent Prefix: It guarantees that users do not see out-of-order writes, but there is no time-bound data replication across regions.
- Eventual: It does not guarantee any time-bound or version bound replication. It has the lowest read latency and level of consistency.