14

Can someone explain how I can configure Azure cosmosDB to not be so expensive? 30€ for 3 days?? It's a small test environment with very few users.

In the backend, I only see that it will cost some cents ...

Here is my Cost overview: Cost Overview

I have around 18 collections but all are only kbits big. It the backend database for the js cms : http://keystonejs.com/

Example scaling for one collection in azure: exampleScaling

Dan Beaulieu
  • 19,406
  • 19
  • 101
  • 135
aumanjoa
  • 905
  • 1
  • 11
  • 30
  • Off topic. Open a support ticket on Azure. They're pretty good about getting back and getting answers. –  May 26 '17 at 15:11
  • 3
    @Will - no need to contact support. This is expected behavior; this is due to the OP allocating 18 collections, each with a minimum cost footprint for reserved performance. – David Makogon May 26 '17 at 16:04
  • Azure Table storage uses storage-based pricing and for the transaction, it is cheap as it costs $0.00036 for 10000 transactions. – Distraction Arrestor Oct 24 '17 at 08:30
  • @DistractionArrestor Keystone cannot use table storage (it requires MongoDB). Plus table storage offers a single index (partition key + row key). To provide further indexes, additional tables must be created (duplicating data). Storage Tables do not offer consistent performance and have both transaction caps and throughput caps. Storage V2 increases performance, but transaction costs increase as well. And note that a storage *transaction* is an underlying REST API call, and there are often multiple transactions per operation. TL;DR apples-to-oranges comparison. – David Makogon Feb 18 '19 at 13:15

2 Answers2

19

The problem is that you are billed by collection. So even if you use only a little storage space and you make only a couple of requests, you have to pay the minimum RU per document collection.

Akos Nagy
  • 4,201
  • 1
  • 20
  • 37
17

You created 18 collections, meaning you have 18 billable database constructs. And with the lowest-cost collection starting at roughly 20 Euro per month (about 5 Euro per 100 RU per month, minimum 400 RU), the math works out: You basically created an environment with 400*18=7200 RU. Perhaps just use fewer collections to reduce your cost footprint (note: collections have no rules around documents being homogeneous). You could use a single collection, since you have such a low amount of data.

EDIT FEB 2018 - note: with database-level RUs (a feature added a few months after the OPs question was posted), the cost model would be very different. 18 collections would be able to share an 1800RU database-level allocation (the minimum is 400RU, up to 4 collections, then 100RU per additional collection). With database-level RU, the cost of an 18-collection configuration would start at 25% of the original cost, based on 400RU per collection.

David Makogon
  • 69,407
  • 21
  • 141
  • 189
  • thanks for the answere. But I can not controle the collection as it comes from keystoneJs. so the only obtion is to use a other database – aumanjoa May 26 '17 at 16:49
  • 1
    Yeah I have 1 single collection with 2 tiny documents totaling maybe a few bytes. No one is hitting it. I've hit it maybe 4 or 5 times testing code. My latest bill was $22.00! Seriously?!?!?! Dumping CosmosDb for sure. – Locohost Jun 13 '18 at 13:50
  • 1
    @Locohost I don't understand the aggressiveness of your comment, or why you chose to rant here as a comment to my answer. FYI you're paying for a database *service*, not just storage of two documents (if you want only storage, I'm sure you can find a cheaper solution, like Blob Storage). So your $22 is paying for a database service with SLA, query engine, and all other features, along with 10GB of storage. And this pricing is clearly documented. – David Makogon Jun 13 '18 at 14:07
  • 17
    @DavidMakogon You've never seen or heard me "aggressive" :-D I'm comparing the cost of CosmosDB with *nothing* in it and *no one* hitting it to my Firebase/Firestore apps. My Firestore DB has maaaaaany collections with MBs of data and I still haven't received a bill higher than $0.00 from Google since last year. MS needs to offer "Free forever developer tiers" for those of us who are just trying learn their tools. If they don't, we'll all stick with Google. – Locohost Jun 14 '18 at 15:24
  • Hi @DavidMakogon, do you have a reference for **database-level RUs**? – Konstantin A. Magg Feb 22 '21 at 19:13
  • @KonstantinA.Magg - check out the Cosmos DB docs, which cover this thoroughly. Same pricing as collection-level, but shared across the collections within the database. – David Makogon Feb 22 '21 at 19:20
  • OK, I could not find the option to set this via Azure Portal. But in the [cosmosdb_mongo_database Terraform Template](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_mongo_database#throughput) this is a single line – Konstantin A. Magg Feb 23 '21 at 13:13