Create a RateLimiter object by calling , which can be created separately for each RocksDB instance or by shared among RocksDB instances to control the aggregated write rate of flush and compaction.

    • : this controls how often tokens are refilled. For example, when rate_bytes_per_sec is set to 10MB/s and refill_period_us is set to 100ms, then 1MB is refilled every 100ms internally. Larger value can lead to burst writes while smaller value introduces more CPU overhead. The default value 100,000 should work for most cases.

    Then each time token should be requested before writes happen. If this request can not be satisfied now, the call will be blocked until tokens get refilled to fulfill the request. For example,

    1. // block if tokens are not enough
    2. Status s = db->Flush();

    Customization

    For the users whose requirements are beyond the functions provided by RocksDB native Ratelimiter, they can implement there own Ratelimiter by extending include/rocksdb/rate_limiter.h