pub struct BackpressureConfig {
pub max_pending_writes: usize,
pub max_pending_reads: usize,
}Expand description
Backpressure configuration for client request flow control
Prevents unbounded memory growth by limiting pending client requests. When limits are reached, new requests are rejected with RESOURCE_EXHAUSTED error until the system processes existing requests.
§Value Semantics
0= unlimited (no backpressure)> 0= maximum pending requests allowed
§Tuning Guidelines(only for reference)
- Low memory (< 4GB): 1000-5000
- Medium memory (4-16GB): 5000-20000
- High memory (> 16GB): 20000-50000
§Example
[raft.backpressure]
max_pending_writes = 10000
max_pending_reads = 50000Fields§
§max_pending_writes: usizeMaximum pending write (propose) requests
Limits the number of client write requests waiting in the leader’s propose buffer. Write requests typically consume more resources (replication, persistence) than reads.
Default: 10000 (0 = unlimited)
max_pending_reads: usizeMaximum pending linearizable read requests
Limits the number of client linearizable read requests waiting in the leader’s read buffer. Read requests can tolerate higher limits as they don’t require replication.
Default: 50000 (0 = unlimited)
Implementations§
Source§impl BackpressureConfig
impl BackpressureConfig
Sourcepub fn should_reject_write(&self, current_pending: usize) -> bool
pub fn should_reject_write(&self, current_pending: usize) -> bool
Check if write request should be rejected due to backpressure
Returns true if the current pending count exceeds the limit.
When max_pending_writes == 0, always returns false (unlimited).
Sourcepub fn should_reject_read(&self, current_pending: usize) -> bool
pub fn should_reject_read(&self, current_pending: usize) -> bool
Check if read request should be rejected due to backpressure
Returns true if the current pending count exceeds the limit.
When max_pending_reads == 0, always returns false (unlimited).
Trait Implementations§
Source§impl Clone for BackpressureConfig
impl Clone for BackpressureConfig
Source§fn clone(&self) -> BackpressureConfig
fn clone(&self) -> BackpressureConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BackpressureConfig
impl Debug for BackpressureConfig
Source§impl Default for BackpressureConfig
impl Default for BackpressureConfig
Source§impl<'de> Deserialize<'de> for BackpressureConfig
impl<'de> Deserialize<'de> for BackpressureConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for BackpressureConfig
impl RefUnwindSafe for BackpressureConfig
impl Send for BackpressureConfig
impl Sync for BackpressureConfig
impl Unpin for BackpressureConfig
impl UnsafeUnpin for BackpressureConfig
impl UnwindSafe for BackpressureConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request