cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

bulkio: improve rate limiting / IO characteristics

Open dt opened this issue 8 years ago • 5 comments

Context: If we use 100% of available IO capacity to do bulk IO in IMPORT or RESTORE, we currently make nodes temporarily slow or even unhealthy (liveness failures). This can interfere with those operations directly -- e.g. IMPORT will start over currently, and may be unable to finish -- but in general though, IMPORT jobs are likely to be run on production clusters, where we should try to avoid impacting the health of the cluster or its ability to serve traffic.

To avoid this, we default to limiting the write rate of bulk IO operations with a setting, but the correct value for this setting depends on the hardware's IO capacity for any individual cluster, any other tasks using that IO capacity, the other load on the cockroach nodes, etc. so a one-size-fits-all value is hard to pick here.

OTOH, RESTORE is often used in a recovery situation, or even initial provisioning, in which case it might just want to finish ASAP, even it impacts cluster health in the meantime.

In the short term, we can document some of these competing concerns with tips and suggestions for operators.

In the longer term, some possible technical improvements:

  • Limit IMPORT and RESTORE addSSTable separately -- by default, IMPORT should prioritize not impacting cluster health while RESTORE probably default should get done ASAP (though this still requires it not kill the cluster in the process).
  • Dynamically determine what a good limit should be, e.g. by discovering the IO capacity with a large (32mb?) write and then picking some % of that. This would let us adapt to whatever hardware we find ourselves on (including with whatever other IO is happening at the test time). We could repeat this test periodically too, but the test itself is of course a concern.
  • Watch disk util stats on that device to determine if we need to adjust our %.
  • Sharing a limiter with RocksDB traffic, requesting our reservations with a low priority (rocks only uses the limiter for compactions and flushes, with compactions low and flushes high -- WAL and such skip it).

Some additional things to think about, beyond just the bytes-per-second, is how many concurrent requests we want to send or handle at different points -- e.g. concurrent import requests might tie up RAM with re-keyed SSTs waiting for the write-rate limiter to get them on to disk. We should look at this end-to-end and ensure that we have appropriate back-pressure at each step, while also rate limiting around the critical resources (so far that seems like disk IO?) to avoid starving other traffic.

dt avatar Feb 15 '18 15:02 dt

cc @mjibson @danhhz @mberhault @a-robinson for thoughts

dt avatar Feb 15 '18 15:02 dt

There are two sides of this we should explore: rate-limiting bulk operations that are intended to run in the background without interfering with production traffic, and prioritizing or somehow protecting the truly critical stuff like liveness updates (whether it's competing with bulk imports or just regular production traffic).

bdarnell avatar Feb 15 '18 15:02 bdarnell

I don't think we should treat RESTORE and IMPORT differently. If either RESTORE or IMPORT cause node liveness failures then their job is restarted. Job restarts can take up to 30s to even start. A RESTORE that keeps ddosing itself won't complete very fast because it'll keep getting stopped and restarted.

madelynnblue avatar Feb 15 '18 19:02 madelynnblue

Some additional things to think about, beyond just the bytes-per-second, is how many concurrent requests we want to send or handle at different points -- e.g. concurrent import requests might tie up RAM with re-keyed SSTs waiting for the write-rate limiter to get them on to disk. We should look at this end-to-end and ensure that we have appropriate back-pressure at each step, while also rate limiting around the critical resources (so far that seems like disk IO?) to avoid starving other traffic.

dt avatar Mar 07 '18 19:03 dt

Likely a KV/Storage issue. But this issue is too broad to be actionable, closing.

shermanCRL avatar Jun 22 '21 19:06 shermanCRL