Skip to main content

WritesSection

Struct WritesSection 

Source
pub struct WritesSection {
    pub ops_per_hour: Option<u32>,
    pub ops_burst: Option<u32>,
    pub bytes_per_hour: Option<u64>,
    pub bytes_burst: Option<u64>,
}
Expand description

How fast one account may write, as two token buckets: one on write operations and one on request bytes. See didbot_serve::write_meter.

Every account shares one write-ahead log, bounded by [capacity] log_budget_bytes and trimmed at [capacity] checkpoint_log_bytes. These keys bound how fast one account can take it: a rate, not a total.

A single createRecord, putRecord or deleteRecord costs one operation and adds about 1 KiB to the log, whatever the record’s size; the body goes to the record heap. applyWrites costs one operation per write, and uploadBlob costs one. Each request’s body costs its length in bytes.

In any hour one account writes at most ops_burst + ops_per_hour operations and bytes_burst + bytes_per_hour bytes. At the defaults that is 4,600 operations, about 4.5 MiB of log (0.2% of the 2 GiB budget a 20 GiB volume gets), and 72 MiB of request bodies. One account writing flat out reaches the 1 GiB watermark that budget defaults to in about nine and a half days, and the server then trims it.

A write over either bucket is refused with 429 RateLimitExceeded and a Retry-After. The buckets are in memory and start full on every start.

Reload: needs a restart. The meter is built once, into the router.

Fields§

§ops_per_hour: Option<u32>

Write operations an account’s bucket regains an hour.

Reasonable range: 600 to 360_000. 600 is one write every six seconds. 360_000 is a hundred a second, about 350 MiB of log an hour from one account, which a deployment should choose only with a large budget. The built-in default is 3_600, one a second: an agent writing every five seconds uses 20% of it.

§ops_burst: Option<u32>

Write operations an account’s bucket holds when full: how many it may write at once before the hourly rate applies.

Reasonable range: 200 to 100_000. Below 200, the most writes one applyWrites takes, a full batch is refused however long the caller waits, so startup refuses it. The built-in default is 1_000, which refills in about 17 minutes at the default rate.

§bytes_per_hour: Option<u64>

Request bytes an account’s bucket regains an hour.

Reasonable range: 8 MiB to 4 GiB (8_388_608 to 4_294_967_296). This bounds how fast one account grows the record heap, which shares the volume with the log and the blobs. The built-in default is 64 MiB (67_108_864): a 1 KiB record every five seconds uses about 1% of it, and a loop of full 2 MiB requests gets one every 112 seconds.

§bytes_burst: Option<u64>

Request bytes an account’s bucket holds when full.

Reasonable range: 2 MiB to 1 GiB (2_097_152 to 1_073_741_824). Below 2 MiB, the largest request body this server reads, a full request is refused however long the caller waits, so startup refuses it. The built-in default is 8 MiB (8_388_608), four full requests.

Trait Implementations§

Source§

impl Clone for WritesSection

Source§

fn clone(&self) -> WritesSection

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for WritesSection

Source§

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

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

impl Default for WritesSection

Source§

fn default() -> WritesSection

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

impl<'de> Deserialize<'de> for WritesSection

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for WritesSection

Source§

fn eq(&self, other: &WritesSection) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for WritesSection

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for WritesSection

Source§

impl StructuralPartialEq for WritesSection

Auto Trait Implementations§

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,