3

Even after reading many articles, I'm still unable to understand what WCU and RCU mean. Dynamo offers the following FREE tier:

  • 25 provisioned Write Capacity Units (WCU)
  • 25 provisioned Read Capacity Units (RCU)

What does "25 reads and writes per second" mean? I have a web application with an API that reads from Dynamo. Does that mean it can only handle 25 queries and writes per second? If yes, what happens if we get 26 read requests in one second?

I'm confused and would appreciate an explanation with a real-world example using a web application.

Bazinga
  • 10,716
  • 6
  • 38
  • 63

1 Answers1

6

As you said, RCU and WCU measures the number of reads and writes (respectively) per second. However, for obvious reasons, doing a 10 byte read is not billed the same as a read of the entire database - one RCU is a read of up to 4KB, and larger reads are counted as multiple reads. WCU uses a smaller quantum (1KB). Another thing you should know is that an eventual consistency read counts as half a RCU, and a transactional read counts as two RCUs. See for example this source.

Your next question is what happens if you provision (i.e., use "Provisioned" billing mode) 25 RCUs, but then try to make 26 requests per second. Well, first of all, 25 is not a hard per-second limit but an average limit. Amazon will let you use 50 RCUs in one second if you used 0 RCUs in the previous second. The details of how exactly this averaging happens and what its period is isn't public, but it is known that in the past Amazon got complaints that people were paying for 25 RCUs and weren't getting 25,000 reads over 1000 seconds, and they acted on these complaints and now you should be able to get 25 reads per second on a long-term average.

Now, to return to your question what happens if you consistently try to send 26 reads per second with just 25 provisioned RCUs, well, some of your requests will fail with ProvisionedThroughputExceededException. Amazon's client libraries will, in such a case, automatically back of and retry the request. So if you're using such a library, it will appear to you like your requests are slowing down until you're getting exactly 25 responses per second, and all requests succeed. This is also explained in the same link I gave above.

Nadav Har'El
  • 11,785
  • 1
  • 24
  • 45
  • 1
    I think what you're describing as "is not known" refers to adaptive capacity, which is [documented](https://aws.amazon.com/blogs/database/how-amazon-dynamodb-adaptive-capacity-accommodates-uneven-data-access-patterns-or-why-what-you-know-about-dynamodb-might-be-outdated/) – Maurice Mar 20 '22 at 19:53
  • You're right that Amazon did publish their new and improved rate-limiting algorithm (the old one sucked, and tended to give you less than you paid for on average) in various presentations and blog post, but you still don't know exactly all the details and parameters involved. But the main takeout is that if you pay for 25 RCUs you're **expected** to get 25 reads per second when averaged over a long duration. It is still possible you'll get 20 reads in one second and 30 in another second, for many different reasons, but 25 will be the average, and that is what you should really care about. – Nadav Har'El Mar 21 '22 at 09:30
  • @NadavHar'El thanks for the answer. Can you explain in terms of CRUD operations? Let's say I set RCU and WCU to 1. Does it mean only **one** client can perform CRUD operations in one second? – Bazinga Mar 27 '22 at 05:56
  • If both RCU and WCU are 1, it roughly means that on average you can do one read and one write operation per second - so that's two CRUD operations... (again, it also depends on the size, and the consistency on the read). A write which conceptually includes a read (e.g., an increment) is only counted as a write - not as both a read and a write. If you have multiple clients, they will "fight" whose request get accepted. If they both use standard AWS libraries, they will probably each get their fair share of the throughput. – Nadav Har'El Mar 27 '22 at 08:54