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
impl Clone for WritesSection
Source§fn clone(&self) -> WritesSection
fn clone(&self) -> WritesSection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WritesSection
impl Debug for WritesSection
Source§impl Default for WritesSection
impl Default for WritesSection
Source§fn default() -> WritesSection
fn default() -> WritesSection
Source§impl<'de> Deserialize<'de> for WritesSection
impl<'de> Deserialize<'de> for WritesSection
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>,
Source§impl PartialEq for WritesSection
impl PartialEq for WritesSection
Source§fn eq(&self, other: &WritesSection) -> bool
fn eq(&self, other: &WritesSection) -> bool
self and other values to be equal, and is used by ==.