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