{"id":10267,"date":"2018-05-31T00:00:00","date_gmt":"2018-05-31T05:00:00","guid":{"rendered":"https:\/\/threecloud.wpengine.com\/post\/cosmos-db-request-units\/"},"modified":"2022-11-30T09:13:00","modified_gmt":"2022-11-30T15:13:00","slug":"cosmos-db-request-units","status":"publish","type":"post","link":"https:\/\/3cloudsolutions.com\/resources\/cosmos-db-request-units\/","title":{"rendered":"Cosmos DB: Request Units"},"content":{"rendered":"<p>In this post about Cosmos DB, I\u2019d like to dive into what Requests Units are and what it means to work with them in Cosmos. A Request Unit, like all other units inside of Azure, compile things like CPU, memory and IOPS, so you have a unified pattern with which to work.<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/_ul_taX7Hnc\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>When it comes to Request Units, we typically work with a baseline of one Request Unit per second that would deliver a 1K JSON file back to you in a Read-only scenario. So, if I want to read 1K size of JSON document that is 1 Request Unit.<\/p>\n<p>Request Units are also done by seconds. As you start to figure out the capacity you\u2019re going to need, you need to remember it\u2019s a per second operation; it essentially gets renewed every second. If I request 20 RUs per second, then every second I get 20 RUs for the region I\u2019m working in.<\/p>\n<p>As for writes, a write operation will require more of these Request Units than a read. Because when you write a document, its doesn\u2019t just write the document in, maybe the actual process of writing the document into the database is 1 Request Unit, but how many indexes must be updated? Each of those will require a partial, full, or even more than one Request Unit.<\/p>\n<p>To update all the indexes, what makes the whole process powerful is the ability to automate some of those processes, but you need to account for that when you\u2019re estimating. I recommend that you look at the Cosmos DB capacity plan provided by Microsoft.<\/p>\n<p>This looks at the number of different operations and helps you estimate based on your average document size and the number of times you\u2019ll read it and write it in a second. Then it will give you a Request Unit recommendation to start with and you can decide to scale up or down as needed.<\/p>\n<p>Another thing to be aware of is, unlike other capacities, you\u2019re buying this capacity up front. It doesn\u2019t carry over, get re-used or go away, as they\u2019re putting an SLA behind the throughput that you\u2019ve requested. So, if you request 20 RUs a second, that\u2019s what you\u2019re getting charged for. That is also the peak in which you\u2019ll be throttled if you go over.<\/p>\n<p>If you end up going to 25 RUs in that second, 5 of those requests will be throttled back and will either get errors in read scenarios or slow down the write process. Once you\u2019re done being throttled, it resets and is ready to go. Most applications can absorb that without being a big deal, but if it happens regularly, you may want to increase the number of RUs so you\u2019re getting the capacity that you need to support your application.<\/p>\n<p>Another point, you\u2019re reserving capacity at the region levels, not your entire application. If you have 5 regions in a read and you have 20 RUs per second set up for the read environment, you\u2019re being charged for 100 RUs since you\u2019re supporting every region at that capacity.<\/p>\n<p>This region level is another area where you\u2019ll have to do some capacity planning to make sure what you\u2019re paying for matches what you need to have as capacity to support your apps. As you build out you\u2019re going to provision per region, with your primary replica a bit higher as you\u2019re going to have more write, as well as read, in that region.<\/p>\n<p>Hopefully I\u2019ve given you a better understanding of Requests Units. Basically, it\u2019s just another unit of measure that we get to build by in Azure, but it\u2019s important to match the scale that you need.<\/p>\n<p>Need further help? Our expert team and solution offerings can help your business with any Azure product or service, including Managed Services offerings. Contact us at 888-8AZURE or\u00a0 <a href=\"mailto:sales@3cloudsolutions.com\">sales@3cloudsolutions.com<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post about Cosmos DB, I\u2019d like to dive into what Requests Units are&mldr;<\/p>\n","protected":false},"author":22,"featured_media":9546,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"categories":[260],"tags":[],"class_list":["post-10267","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-ai","topics-blog"],"acf":[],"_links":{"self":[{"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/posts\/10267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/comments?post=10267"}],"version-history":[{"count":0,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/posts\/10267\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/media\/9546"}],"wp:attachment":[{"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/media?parent=10267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/categories?post=10267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/3cloudsolutions.com\/wp-json\/wp\/v2\/tags?post=10267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}