Skip to main content

Aimd

Struct Aimd 

Source
pub struct Aimd { /* private fields */ }
Expand description

AIMD (Additive Increase / Multiplicative Decrease) concurrency limit strategy.

A loss-based algorithm that increases the limit by a fixed amount on success and multiplies it by a backoff ratio on error or timeout. This is the same approach used in TCP Reno congestion control.

Unlike Vegas, AIMD does not track baseline RTT or estimate queue depth — it reacts purely to errors and timeouts, making it simpler but less proactive.

§Differences from Netflix’s Java implementation

The Java reference truncates the limit to an integer after every update, while this implementation keeps it as an f64 internally. This means repeated backoffs decay more smoothly (e.g. 10.0 → 9.0 → 8.1 → 7.29 instead of 10 → 9 → 8 → 7). The observable limit (via max_concurrency) is the same in most cases, but after recovery the internal state may be slightly higher than the Java equivalent, leading to marginally faster ramp-up.

Implementations§

Source§

impl Aimd

Source

pub fn builder() -> AimdBuilder

Returns an AimdBuilder for configuring a new Aimd instance.

Trait Implementations§

Source§

impl Algorithm for Aimd

Source§

fn max_concurrency(&self) -> usize

Returns the maximum number of concurrent requests the algorithm currently allows. Read more
Source§

fn update( &mut self, rtt: Duration, num_inflight: usize, is_error: bool, is_canceled: bool, )

Observes the outcome of a request and updates the algorithm’s state accordingly. Read more
Source§

impl Clone for Aimd

Source§

fn clone(&self) -> Aimd

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Aimd

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Aimd

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Aimd

§

impl RefUnwindSafe for Aimd

§

impl Send for Aimd

§

impl Sync for Aimd

§

impl Unpin for Aimd

§

impl UnsafeUnpin for Aimd

§

impl UnwindSafe for Aimd

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.