CosmoDB-多区域集合的事务级别

I have a USER collection which stores user information. Every item will these 3 fields:

-UserID
-Username
-Email

If in the future I need to make this collection available across different regions I understand there are 5 different consistency levels (strong, bounded staleness, session, consistent prefix, and eventual consistency). If I want to guarantee that two users in two different regions do not create the same user (with either the same userid or username or email) at the same time is my only option then strong consistency? A followup question, if I set this collection to be strong, do all my other collections also have to be strong or can I set the consistency level of different collections to different levels (For e.g USER collection is strong and POSTS are eventual)?

评论
  • in_id
    in_id 回复

    Multi-master can only be configured to have a weaker consistency than strong. So, CosmosDB cannot stop two different regions create the same user concurrently but it gives you the ability to do conflict resolution When such a conflict occurs, you can resolve the conflict by using different conflict resolution policies. https://docs.microsoft.com/en-us/azure/cosmos-db/conflict-resolution-policies

    您可以随时在Azure Cosmos帐户上配置默认一致性级别。在您的帐户上配置的默认一致性级别适用于该帐户下的所有Azure Cosmos数据库和容器。默认情况下,对容器或数据库发出的所有读取和查询都使用指定的一致性级别。

    可以为每个请求设置一致性级别,该级别将覆盖在帐户级别设置的默认一致性级别。但是客户端替代只能弱于在帐户级别配置的默认一致性级别。

    如果您需要特定于集合的默认一致性级别,则应将具有相同默认一致性级别需求的集合放在一个帐户中。