Apache Cassandra 和 Azure Cosmos DB 一致性级别Apache Cassandra and Azure Cosmos DB consistency levels

适用于: Cassandra API

与 Azure Cosmos DB 不同,Apache Cassandra 本身并不提供精确定义的一致性保证。Unlike Azure Cosmos DB, Apache Cassandra does not natively provide precisely defined consistency guarantees. 与之相反,Apache Cassandra 提供一个写入一致性级别和一个读取一致性级别,以便进行高可用性、一致性和延迟方面的权衡。Instead, Apache Cassandra provides a write consistency level and a read consistency level, to enable the high availability, consistency, and latency tradeoffs. 使用 Azure Cosmos DB 的 Cassandra API 时:When using Azure Cosmos DB's Cassandra API:

  • Apache Cassandra 的写入一致性级别映射到在 Azure Cosmos 帐户上配置的默认一致性级别。The write consistency level of Apache Cassandra is mapped to the default consistency level configured on your Azure Cosmos account. 写入操作 (CL) 的一致性不能因请求的不同而(即按请求)更改。Consistency for a write operation (CL) can't be changed on a per-request basis.

  • Azure Cosmos DB 会将 Cassandra 客户端驱动程序指定的读取一致性级别动态映射到根据读取请求动态配置的某个 Azure Cosmos DB 一致性级别。Azure Cosmos DB will dynamically map the read consistency level specified by the Cassandra client driver to one of the Azure Cosmos DB consistency levels configured dynamically on a read request.

映射一致性级别Mapping consistency levels

下表演示了在使用 Cassandra API 时,如何将本机 Cassandra 一致性级别映射到 Azure Cosmos DB 的一致性级别:The following table illustrates how the native Cassandra consistency levels are mapped to the Azure Cosmos DB's consistency levels when using Cassandra API:

Cassandra 一致性模型映射

如果使用非常一致性以外的一致性级别配置了 Azure Cosmos 帐户,则可以通过查看概率有限过期 (PBS) 指标,找到客户端获得工作负荷的非常一致读取的概率。If your Azure Cosmos account is configured with a consistency level other than the strong consistency, you can find out the probability that your clients may get strong and consistent reads for your workloads by looking at the Probabilistically Bounded Staleness (PBS) metric. 此指标在 Azure 门户中公开,若要了解详细信息,请参阅监视概率有限过期性 (PBS) 指标This metric is exposed in the Azure portal, to learn more, see Monitor Probabilistically Bounded Staleness (PBS) metric.

概率有限过期表明了最终一致的最终程度。Probabilistic bounded staleness shows how eventual is your eventual consistency. 通过此指标可深入了解在 Azure Cosmos 帐户中目前配置的一致性级别之间获得更非常一致性的频率。This metric provides an insight into how often you can get a stronger consistency than the consistency level that you have currently configured on your Azure Cosmos account. 换句话说,可看到获得写入和读取区域组合的非常一致读取的概率(以毫秒计量)。In other words, you can see the probability (measured in milliseconds) of getting strongly consistent reads for a combination of write and read regions.

后续步骤Next steps

详细了解 Azure Cosmos DB 的多区域分发和一致性级别:Learn more about multiple-region distribution and consistency levels for Azure Cosmos DB: