DataStax Academy FAQ

DataStax Academy migrated to a new learning management system (LMS) in July 2020. We are also moving to a new Cassandra Certification process so there are changes to exam bookings, voucher system and issuing of certificates.

Check out the Academy FAQ pages for answers to your questions:


question

victor_188679 avatar image
victor_188679 asked ·

What is the recommendation for modeling partitions in a multi-tenant application?

we have a multi-tenant application, we always filter tenant id first to get the data for a particular tenant then process them. however, 15% of our tenants have 80% of data, so if we use tenant id as the partition key, we will have hot spots. since we always want tenant data in the same cluster, is it ok to use tenant_id as the partition key in this case?

data modeling
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Erick Ramirez avatar image
Erick Ramirez answered ·

If using just the tenant_id as the partition key results in very large partitions for your table, you should add another column in the partition key (in the primary key) to "bucket" your data and make the partitions smaller.

If you have tables with a clustering column like:

    PRIMARY KEY ( tenant_id, clustering_col )

you will need to add another column to the partition key like this:

    PRIMARY KEY ( (tenant_id, bucket_col), clustering_col )

The primary requirement when modeling data is to design a table for each application query. I mention this because your question is quite specific and answering your question directly doesn't always achieve the optimal outcome you're after.

It's a little difficult for me to provide an informed answer with limited information. If you update your original post with some sample "app questions" (in plain English preferably) so I get an idea of the kind of queries your app is issuing, I'd be happy to update my answer with better guidance. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

victor_188679 avatar image
victor_188679 answered ·

this is good enough for now, let me think more about using multiple columns for the partition key.

1 comment Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Not a problem. Feel free to make a new post if you've got any more questions. Cheers!

1 Like 1 · ·