My apologies if the question is too basic but the description is not entirely clear to me
Read operations to the database.
Atlas calculates RPUs based on the number of read operations, document bytes read (in 4KB increments), and index bytes read (in 256 byte increments) per operation. RPUs are calculated on a daily basis and start at 0 each day.
Just to see if I get it right:
Case 1 - I searched database and got a result of size 3KB - that’s 1 read operation? Or two because its ready operation + size of the result
Case 2 - I searched collection and got a result of size 4,097 B- that’s 2 read operations
Case 3 - Im exploring the database using Atlas and opened a collection with 20 documents each having size of 4KB - that’s 20 read operations just by clicking on database name? And if tap to go to the next page will be another 20 operations?
Case 4 - using atlas or programmatically - is connecting to the database and retrieving the basic state of databases (storage size, collections) counts as one read operation or is free?
mongoClient.getDatabase(DB_NAME).getCollection<ItemDescription>(COLLECTION_NAME).find(Filters.eq(CustomOrder::product_id.name, "item"))
In the example above, assuming it returns single or multiple results of size less than 4KB - would it count as 1 read operation or 3 because of getDatabase(DB_NAME) + getCollection + result ?
Also, is there a way to put hard size limits on returned results besides limiting how many documents to return?
Thanks!
Hi Dominykas_Zaksas
Thank you for the question. Here are a few public resources to help get a better understanding of how RPUs are calculated:
- https://www.mongodb.com/docs/atlas/billing/serverless-instance-costs/
- Frequently Asked Questions - Atlas Serverless Instances
- How to Optimize Your Serverless Instance Bill with Indexing | MongoDB
Atlas calculates RPUs based on the number of read operations, document bytes read (in 4KB increments), and index bytes read (in 256 byte increments) per operation. Keep in mind that you are charged $0.10 for the first million RPUs. Therefore your first 100k RPUs (until you hit $0.01 per day) are “free”.
To answer the questions above:
Case1: The number of RPUs would be dependent on how many documents are being scanned. Not on the number of documents that are returned. Please see the 3rd link pasted above for more details on how RPUs change with and without indexes.
Case2: Same answer as above. The RPUs would be based on how many documents and indexes were scanned to find the documents that were returned.
Case3: Correct, you are charged RPUs for viewing this page. Although, you won’t be charged 20 RPUs because a single operation can fetch multiple documents.
Case4: No, commands that are use for administrative purposes do not count towards RPUs
There is no way to put a limit on how many documents are scanned. You can however, set alerts on RPUs so that you receive alerts if it crosses a certain threshold. You can also make sure that every operation you run uses an Index to mitigate expensive operations that might have to scan all of the documents.
Please let me know if you have any further questions.
Best,
Anurag
I see, so it’s very easy to make mistakes if not using index data or billing alerts
To me, a dedicated server sounds like the safest option as it is flat fee + data transfer a.k.a. size of returned results and nothing else
One more question - for the free tier and dedicated server - is it possible to get data on RPUs or write operations even if that info is seemingly irrelevant?
Thanks, Anurag, for explaining stuff and great URLs - I’ve missed them
Although it is easy to miss indexing, the cost of the not having indexing should not be much (depends on how many documents you have and how many times you are running inefficient queries). Therefore, testing your workload on serverless for a day before deciding to move to dedicated could be a good path to go down. Also, if your workload is not predictable, serverless is the recommended option as it scales quicker than dedicated. Having said that dedicated is a great option if your workload is predictable.
At this point, we don’t have a way to get RPUs on Free Tier and Dedicated Tiers. This is on our roadmap. For WPUs, you can estimate WPUs per document by estimating the size of your writes per document and dividing it by 1kb. For example, if you write 4kb, that would be 4WPUs. You are ignoring the writes to the index using this method, however, you will get a good estimate of the WPUs.
If you are running your workload on Serverless, you can get your RPU estimate by:
- Looking at the “Monitoring” tab that has a chart of Reads/Writes per second
- Setting alerts
- Using the explain command with **To estimate Documents Scanned you can use the “explain” command with “executionStats” and add the docUnitsRead and idxEntryUnitsRead to get an estimation of the number of documents scanned for RPUs.
Hope this helps, please let me know if you have any questions.