4

I have read in a blog that I could "make" a dynamodb table multi tenant using the tenant id as the partition key and for e.g. the sort key as the customer id.

It's sounds good, but imagine that I have a big workload for a tenant id = X, so I am going to have big workload on the same partition.

Is it better to create a hash key that is the concatenate the tenantid + customerid, so i will not have a hotspot?

Community
  • 1
  • 1
p.magalhaes
  • 7,595
  • 10
  • 53
  • 108

1 Answers1

3

Yes, you can, depending on your access pattern.

Whenever you want to Get or Query items from a DynamoDB table, you need to provide the exact partition-key. If you don't do that, you can only Scan, which is a costly operation.

If you'll mostly be interested in data at tenant-id + customer-id>, then it makes sense to make it partition-key. If you won't have customer-id, then you should keep tenant-id as partition-key.

ketan vijayvargiya
  • 5,409
  • 1
  • 21
  • 34