2

I have created a "Free" Cosmos DB account (SQL API) in my Azure Subscription. In that account, I have created a database with shared throughput (400 RU/s) and that database has a container which will utilize database's throughput (there is only one container in the database).

I am now trying to insert some items in my container using batch. Each batch contains exactly 100 items (each item is less than 1K) and I am trying to create 5000 entities (i.e. 50 batches). Each batch insert is consistently consuming 780.95 RUs.

Considering the throughput configured is only 400 RU/s, I was expecting that some of my requests to be throttled however to my surprise all of my requests were successful. I also monitored the total time taken (both end-to-end and time taken by server) and they were respectively 30 seconds and 3 seconds approximately. The total throughput consumed was 39047.50.

enter image description here

I also checked the monitoring to ensure that the service is not throttling any requests (in case SDK is retrying throttled requests) but there also did not find any throttled requests.

enter image description here

Here's the log for 1st 10 requests (remaining requests are more or less the same):

Overall time taken (end-to-end): 30605 ms
Overall time taken (request): 2733.6059999999993 ms
Overall RUs consumed: 39047.49999999999
===========================================
Batch #    Status Code    Request Charge Time (E2E) (ms)    Time (Request) (ms)
001        OK             780.95         7018               56.262
002        OK             780.95         531                53.618
003        OK             780.95         474                51.65
004        OK             780.95         504                54.668
005        OK             780.95         488                56.367
006        OK             780.95         487                50.501
007        OK             780.95         513                54.459
008        OK             780.95         486                55.089
009        OK             780.95         483                65.06

I am curious to know as to why my requests are not getting throttled?

I read about RU debt (here and here) however the math does not add up. If I consider 30 seconds as the total time period, then RUs available to me is 12000 (400 RU/s x 30 seconds) and if I consider 3 seconds as the total time period, then RUs available to me is 1200 (400 RU/s x 3sec). Both of these numbers are way less than 39000 RUs consumed by my application and my requests should have been throttled but none of the requests got throttled.

Any insights into this will be highly appreciated.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • The SDK does some level of retries automatically, which you can check in the cloud if you look at the "Total Requests" metric and split by status code. However, this would still not explain how you get 39000RUs in 30s. You can check the "provisioned throughput" metric to make sure you only had 400 provisioned throughout, and no autoscaling happened. – Alex AIT May 08 '21 at 16:54
  • 1
    Alex - I did check that and there were no throttling errors. All requests succeeded with 200 status code. Also double checked the provisioned throughput. It is indeed manual 400 RU/s. Thanks. – Gaurav Mantri May 08 '21 at 16:59

1 Answers1

0

That's not how free tier works. It simply makes the first 400 RU/s free for use.

This is fairly common misunderstanding. We are working on a throughput cap feature that would rate limit free tier and other accounts. For now you will need to monitor.

Mark Brown
  • 8,113
  • 2
  • 17
  • 21
  • Thanks Mark. So if I understand you correctly, in the free tier setting the throughput to 400 RU/s does not really mean anything. I was under the impression that in free tier, what ever throughput I provision, first 400 RUs are free. So if I provision 1000RU/s, I will only pay for 600 RUs. Is this not correct? – Gaurav Mantri May 08 '21 at 15:06
  • 2
    Oh I see. I thought you were running autoscale or something. Standard provisioned throughput should have limited you here. There are instances where we do let you scale above the provisioned amount but not by much and not for very long. I would open a support ticket and ask if you got billed for this. Billing tickets don't cost anything. If you did, then I would ask for a refund above the 400 amount. – Mark Brown May 08 '21 at 15:41
  • 1
    Thanks Mark! I checked again and the database throughput is set at 400RU/s in manual mode. Regarding refund, That was my next question :). I will check tomorrow morning my time if I got billed for over 400 RUs consumption. I will raise a support request accordingly. But my question remains - why was I not throttled? How can we find that out? – Gaurav Mantri May 08 '21 at 15:47
  • I can't say for sure. Sometimes the rate limiter does not kick in right away. Not sure if support can say for sure but they might. – Mark Brown May 08 '21 at 16:25
  • Mark - Just an update on this issue: It's been 48 hours and I am yet to see the charges posted in my Subscription. How can we check if there's an issue with the service itself or some issue with billing? Thanks. – Gaurav Mantri May 10 '21 at 14:57
  • Raise a support ticket like I mentioned. – Mark Brown May 10 '21 at 16:21