1

I recently set up a free CockroachDB Serverless cluster on CockroachCloud. It's been really great so far, but sometimes there are random spikes in Request Units even though the amount of SQL statements doesn't increase at all. Here's a screenshot of the two graphs in the cluster management page, it illustrates pretty well what I mean. I would really appreciate some help on how I could eliminate these spikes because CockroachCloud has some limits on free usage. That being said, I'm still fairly new to CockroachDB, so I might be missing something obvious.

Gadget
  • 183
  • 1
  • 7
  • seems the burst limit is 10kk month and it should last you with those spikes, but what is your backend, you should limit things there, it barely has anything to do with database, or? Meaning what is your backend and how you set it up – MolbOrg Oct 22 '21 at 08:05
  • @MolbOrg I already set up limits in my backend, I don't think that's the issue. As you can see from the bottom graph in the [screenshot](https://i.stack.imgur.com/5nm0Y.png), the number of SQL statements is very stable. That's why I think that the problem is related to the database itself. – Gadget Oct 22 '21 at 08:23
  • yes, after reading and looking at stuff, those RU can be different based on database structure and requests and such. To identify is it DB side or backend side - it probably needs to try to establish some correlation in time between your side - did you try to approximately locate any correlation with what's going on around those spikes on your end - if there is nothing unusual, maybe it makes sense to ask support from them, so they can help you pinpoint what activity causes that theirs or backend. Generally, it needs to locate heavy query, classify them and try to identify computing heavy ones – MolbOrg Oct 22 '21 at 09:18
  • You start out with 10 million RUs to cover bursts at the beginning of the month, and then earn 100 RUs per second afterward. When your cluster's load is below 100 RUs per second, you accumulate RUs that can be used for bursts. So in your graph, all the time spent below the green line you were accumulating RUs. – Ian Evans Oct 22 '21 at 16:18

1 Answers1

2

You are likely performing enough mutations on your data to trigger automatic statistics collection as a background process. By default when 20% or more rows are modified in a table, CockroachDB will trigger a statistics refresh. The statistics are used by the optimizer to create more efficient query plans.

Your SQL Statements graph indicates that almost all your operations are inserts. That many inserts is almost certainly triggering stats collection. While you can turn off stats collection, the optimizer will then be using stale data to calculate query plans, potentially causing performance problems.

The occasional spikes in your Request Unit graph are above the 100 RUs per second baseline, but the rest of the time you are well below 100 RUs per second. That means you are accumulating RUs most of the time, and that (plus the initial 10 million RU allocation) should cover the bursts.

I added a FAQ entry to the Serverless docs covering this.

Ian Evans
  • 1,357
  • 10
  • 10