ava-innersource / Liquid-Application-Framework-1.0-deprecated

Liquid is a framework to speed up the development of microservices
MIT License
25 stars 14 forks source link

Define a CosmosDB PartitionKey for collections #200

Open andreracz opened 4 years ago

andreracz commented 4 years ago

Today, the PartitionKey is fixed with undefined value. This could impact scalability.

The main issue here is how to do this in a Database agnostic manner

bruno-brant commented 4 years ago

So, from what we gathered:

This issue is somewhat important; right now Liquid does the following:

Users can use the Azure Portal to define better partitions key, but currently Liquid won't let the application inform the partition on a query, which leads to increased consumption.

andreracz commented 4 years ago

Actually, the cross-partition queries are done for Queries only, for Update, GetById and Delete, the information is searched using a default partition value of Undefined. This has some bad implications:

The easiest fix, that does not require code changes, but will require that the Collections are recreated and Data is migrated is to use the id as a Partition Key. Implications:

This seems like a good solution for version 1.0, but we should implement a more flexible approach that allows the user to choose a suitable partition key for future versions.

@bruno-brant and @guilhermeluizsp, I would like your opinion on this.

Also, I would label this a bug, due to the severity.

guilhermeluizsp commented 4 years ago

@andreracz I think you've said it all and I also agree to use id as the default partition key, for now.

@bruno-brant I believe this should be one of the highest priorities. Shouldn't we move it to the 1.0.0 milestone (@andreracz also mentioned it)?

bruno-brant commented 4 years ago

I agree, prioritizing it given the kind of issues could stem from this.

bruno-brant commented 4 years ago

I'm marking it as a bug because a number of issues could arise in production if we don't treat this correctly.

bruno-brant commented 4 years ago

One thing that I forgot to mention is that choosing Id as the primary has one downside: transactions can only occur on a single partition, so we are essentially losing the capability to use transactions.

andreracz commented 4 years ago

@bruno-brant, I've created a pull-request (#216) with the fix, the Unit Tests are not implemented yet.