Package org.rocksdb
Class RateLimiter
java.lang.Object
org.rocksdb.AbstractNativeReference
org.rocksdb.AbstractImmutableNativeReference
org.rocksdb.RocksObject
org.rocksdb.RateLimiter
- All Implemented Interfaces:
AutoCloseable
RateLimiter, which is used to control write rate of flush and
compaction.
- Since:
- 3.10.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final intstatic final RateLimiterModestatic final longFields inherited from class org.rocksdb.RocksObject
nativeHandle_Fields inherited from class org.rocksdb.AbstractImmutableNativeReference
owningHandle_ -
Constructor Summary
ConstructorsConstructorDescriptionRateLimiter(long rateBytesPerSecond) RateLimiter constructorRateLimiter(long rateBytesPerSecond, long refillPeriodMicros) RateLimiter constructorRateLimiter(long rateBytesPerSecond, long refillPeriodMicros, int fairness) RateLimiter constructorRateLimiter(long rateBytesPerSecond, long refillPeriodMicros, int fairness, RateLimiterMode rateLimiterMode) RateLimiter constructorRateLimiter(long rateBytesPerSecond, long refillPeriodMicros, int fairness, RateLimiterMode rateLimiterMode, boolean autoTune) RateLimiter constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected final voiddisposeInternal(long handle) longReturns the bytes per second.longMax bytes can be granted in a single burst.longTotal bytes that go through rate limiter.longTotal # of requests that go through rate limiter.voidrequest(long bytes) Request for token to write bytes.voidsetBytesPerSecond(long bytesPerSecond) This API allows user to dynamically change rate limiter's bytes per second.Methods inherited from class org.rocksdb.RocksObject
disposeInternal, getNativeHandleMethods inherited from class org.rocksdb.AbstractImmutableNativeReference
close, disOwnNativeHandle, isOwningHandle
-
Field Details
-
DEFAULT_REFILL_PERIOD_MICROS
public static final long DEFAULT_REFILL_PERIOD_MICROS- See Also:
-
DEFAULT_FAIRNESS
public static final int DEFAULT_FAIRNESS- See Also:
-
DEFAULT_MODE
-
DEFAULT_AUTOTUNE
public static final boolean DEFAULT_AUTOTUNE- See Also:
-
-
Constructor Details
-
RateLimiter
public RateLimiter(long rateBytesPerSecond) RateLimiter constructor- Parameters:
rateBytesPerSecond- this is the only parameter you want to set most of the time. It controls the total write rate of compaction and flush in bytes per second. Currently, RocksDB does not enforce rate limit for anything other than flush and compaction, e.g. write to WAL.
-
RateLimiter
public RateLimiter(long rateBytesPerSecond, long refillPeriodMicros) RateLimiter constructor- Parameters:
rateBytesPerSecond- this is the only parameter you want to set most of the time. It controls the total write rate of compaction and flush in bytes per second. Currently, RocksDB does not enforce rate limit for anything other than flush and compaction, e.g. write to WAL.refillPeriodMicros- 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 burstier writes while smaller value introduces more CPU overhead. The default of 100,000us should work for most cases.
-
RateLimiter
public RateLimiter(long rateBytesPerSecond, long refillPeriodMicros, int fairness) RateLimiter constructor- Parameters:
rateBytesPerSecond- this is the only parameter you want to set most of the time. It controls the total write rate of compaction and flush in bytes per second. Currently, RocksDB does not enforce rate limit for anything other than flush and compaction, e.g. write to WAL.refillPeriodMicros- 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 burstier writes while smaller value introduces more CPU overhead. The default of 100,000us should work for most cases.fairness- RateLimiter accepts high-pri requests and low-pri requests. A low-pri request is usually blocked in favor of hi-pri request. Currently, RocksDB assigns low-pri to request from compaction and high-pri to request from flush. Low-pri requests can get blocked if flush requests come in continuously. This fairness parameter grants low-pri requests permission by fairness chance even though high-pri requests exist to avoid starvation. You should be good by leaving it at default 10.
-
RateLimiter
public RateLimiter(long rateBytesPerSecond, long refillPeriodMicros, int fairness, RateLimiterMode rateLimiterMode) RateLimiter constructor- Parameters:
rateBytesPerSecond- this is the only parameter you want to set most of the time. It controls the total write rate of compaction and flush in bytes per second. Currently, RocksDB does not enforce rate limit for anything other than flush and compaction, e.g. write to WAL.refillPeriodMicros- 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 burstier writes while smaller value introduces more CPU overhead. The default of 100,000us should work for most cases.fairness- RateLimiter accepts high-pri requests and low-pri requests. A low-pri request is usually blocked in favor of hi-pri request. Currently, RocksDB assigns low-pri to request from compaction and high-pri to request from flush. Low-pri requests can get blocked if flush requests come in continuously. This fairness parameter grants low-pri requests permission by fairness chance even though high-pri requests exist to avoid starvation. You should be good by leaving it at default 10.rateLimiterMode- indicates which types of operations count against the limit.
-
RateLimiter
public RateLimiter(long rateBytesPerSecond, long refillPeriodMicros, int fairness, RateLimiterMode rateLimiterMode, boolean autoTune) RateLimiter constructor- Parameters:
rateBytesPerSecond- this is the only parameter you want to set most of the time. It controls the total write rate of compaction and flush in bytes per second. Currently, RocksDB does not enforce rate limit for anything other than flush and compaction, e.g. write to WAL.refillPeriodMicros- 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 burstier writes while smaller value introduces more CPU overhead. The default of 100,000us should work for most cases.fairness- RateLimiter accepts high-pri requests and low-pri requests. A low-pri request is usually blocked in favor of hi-pri request. Currently, RocksDB assigns low-pri to request from compaction and high-pri to request from flush. Low-pri requests can get blocked if flush requests come in continuously. This fairness parameter grants low-pri requests permission by fairness chance even though high-pri requests exist to avoid starvation. You should be good by leaving it at default 10.rateLimiterMode- indicates which types of operations count against the limit.autoTune- Enables dynamic adjustment of rate limit within the range[rate_bytes_per_sec / 20, rate_bytes_per_sec], according to the recent demand for background I/O.
-
-
Method Details
-
setBytesPerSecond
public void setBytesPerSecond(long bytesPerSecond) This API allows user to dynamically change rate limiter's bytes per second. REQUIRED: bytes_per_second > 0
- Parameters:
bytesPerSecond- bytes per second.
-
getBytesPerSecond
public long getBytesPerSecond()Returns the bytes per second.- Returns:
- bytes per second.
-
request
public void request(long bytes) Request for token to write bytes. If this request can not be satisfied, the call is blocked. Caller is responsible to make sure
bytes < GetSingleBurstBytes().- Parameters:
bytes- requested bytes.
-
getSingleBurstBytes
public long getSingleBurstBytes()Max bytes can be granted in a single burst.
- Returns:
- max bytes can be granted in a single burst.
-
getTotalBytesThrough
public long getTotalBytesThrough()Total bytes that go through rate limiter.
- Returns:
- total bytes that go through rate limiter.
-
getTotalRequests
public long getTotalRequests()Total # of requests that go through rate limiter.
- Returns:
- total # of requests that go through rate limiter.
-
disposeInternal
protected final void disposeInternal(long handle) - Specified by:
disposeInternalin classRocksObject
-