Jason
Jason

Reputation: 2076

Is Cassandra's hash for same value across multiple tables?

I have a multi-tenant application where tenantId would be part of every query, so I am putting it into the partition key for all tables.

EXAMPLES:

CREATE TABLE users {
tenantId text,
user text,
active boolean,
PRIMARY_KEY (tenantId, user)
}

CREATE TABLE roles {
tenantId text,
rolename text,
PRIMARY_KEY (tenantId, rolename)
}

Now, imagine 100s of tables like these...

My question is:

Will Cassandra hash the tenantId 'foo' to point ALL data from ALL tables to the same node and make it a uber hotspot or will it evenly distribute each table & tenant data around the cluster evenly?

Upvotes: 4

Views: 774

Answers (1)

doanduyhai
doanduyhai

Reputation: 8812

Simple answer, the token value (hash of the partition key) is the same and it does not depend on the table name or whatever. The reason is that we use the same partition (Murmur3) within the whole cluster.

So in your case, yes, if your partition key is tenantId, all data from one customer will be distributed to the same replicas, and this applies for all tables having this partition key

Upvotes: 5

Related Questions