Elfocrash / Cosmonaut

🌐 A supercharged Azure CosmosDB .NET SDK with ORM support
https://cosmonaut.readthedocs.io
MIT License
342 stars 44 forks source link

Shared throughput on DB level #67

Closed Mortana89 closed 5 years ago

Mortana89 commented 5 years ago

Hello,

I could not find this directly in the documentation, but, Cosmos DB, since recently, allows to define a shared throughput on DB level, instead of collection level. As such, I want Cosmonaut to not set a fixed throughput on collection level when creating the collection. How can I achieve this?

Elfocrash commented 5 years ago

Hello @Mortana89

Let me get this straight. If you provision database throughput and then run Cosmonaut against that database, will it create collections with dedicated throughput on top of the database throughput?

Mortana89 commented 5 years ago

That's indeed correct!

Elfocrash commented 5 years ago

Oh, we don't want that. I will have to verify the behaviour locally but if that is the case then I will add a check to see if the collection has an offer, and if it does, then the throughput value on the collection level will be ignored.

For now, I recommend provisioning your database and your collections before you start using Cosmonaut against them, if you want database level provisioning.

Mortana89 commented 5 years ago

Oh, we don't want that. I will have to verify the behaviour locally but if that is the case then I will add a check to see if the collection has an offer, and if it does, then the throughput value on the collection level will be ignored.

For now, I recommend provisioning your database and your collections before you start using Cosmonaut against them, if you want database level provisioning.

Thanks. I will for now. Currently I use cosmonaut in a microservice, which creates a collection per 'event' it receives, but we're still in development so I can cope with manually changing this in Cosmos DB as it isn't doing this many times. The emulator is a bit tricky to spot this issue, but you can easily see it in the Azure instance. All collections that are shared, have this indicated on the homepage of the Cosmos DB resource: image

The emulator also supports this sharing on DB level, but it doesn't visualize it as clearly.

Elfocrash commented 5 years ago

I am wondering. Why do you go about it that way? You you mean one collection per event type? One collection per event (single document) wouldn't make sense.

Mortana89 commented 5 years ago

I am wondering. Why do you go about it that way? You you mean one collection per event type? One collection per event (single document) wouldn't make sense.

It's a multi-tenant application, once a tenant is registered, we need to approve his registration. Approving his registration fires a 'TenantApproved' event on our bus, an all our microservices do their work (like, creating a dedicated collection for this tenant to store microservice specific data).

Elfocrash commented 5 years ago

Ok i just verified that it's an issue. I will be fixing that issue by adding an extra property on the settings.

Something like.

Does this sound good?

Mortana89 commented 5 years ago

Ok i just verified that it's an issue. I will be fixing that issue by adding an extra property on the settings.

Something like.

  • OnDatabaseThroughput = ThroughputBehaviour.UseCollectionThroughput
  • OnDatabaseThroughput = ThroughputBehaviour.UseDatabaseThroughput

Does this sound good?

Sounds perfect! Thanks!

Elfocrash commented 5 years ago

Fixed and feature added in 2.9.0

Thanks for the request.

Mortana89 commented 5 years ago

Thanks for implementing!

Elfocrash commented 5 years ago

Don't forget to star the project if you like it. It helps with visibility :)