Explain it simpler
Cosmos DB charges for work in a single made-up currency called Request Units, or RUs. Reading one small document when you know exactly where it is costs about one RU, like grabbing a book from a shelf when you know its spot. Searching the whole library costs much more. Every time you save a document, Cosmos DB also updates its index, which is like a book's back-of-the-book index; if you index every word, every save takes longer and costs more. You can tell it to skip fields you never search. Finally, asking for the very freshest, most guaranteed-correct answer from every copy of your data (strong consistency) costs about double for reads, so only pay for it when you truly need it.
The finance lead at Bluebird Learning, a fictional online tutoring company, forwards you the monthly Azure bill with one line highlighted: Cosmos DB costs have tripled since the team launched its new document search feature. Nobody added traffic on purpose. You open a sample response in the debugger and notice a header called x-ms-request-charge showing that saving one lesson document costs dozens of units, and reading one by id costs several more than it should. The account is also set to Strong consistency because someone thought stronger sounded safer. Where is the money actually going, and which settings can you change today?
Cosmos DB measures every operation in Request Units (RUs), a single currency that blends CPU, memory and input/output (I/O). Instead of sizing servers, you provision throughput as RU per second, either manual or autoscale, or you choose serverless mode and pay for the RUs you actually consume. If your requests exceed your provisioned RU/s in a given second, Cosmos DB rate-limits them with HTTP 429 and a retry-after hint, and the SDK waits and retries a limited number of times. Every response reports its cost in the x-ms-request-charge header. In the Python SDK you can read it from the last response headers on the client connection after each call, so you can measure rather than guess, and it is worth logging during development.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 6 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.