-
Notifications
You must be signed in to change notification settings - Fork 795
RC Bandwidth Parameters
Each pool has its own values of the following constants:
-
budget_time
: Time interval for budgeting. -
budget
: How much the resource increases linearly overbudget_time
. -
half_life
: Time until the resource would decay to 50% of its initial size with no load or budget. -
drain_time
: Time until user RC would decrease to 0% of its capacity in the hypothetical world where all users have saved maximum RC, use all RC and RC regen on this resource, and the resource increases with budget but does not decay. -
inelasticity_threshold
: Percentage of the equilibrium value that serves as a boundary between elastic and inelastic prices.
Let us analyze the dynamics of the resource budget pool as outlined here with an eye to establishing values of the parameters.
Let p(x)
be the RC cost curve, p(x) = A / (B + x)
.
Let's denote as p_0
the value of p(0)
, which is of course p_0 = A / B
. In other words,p_0
is the price when there are no resources in the pool. Let's set up a worst-case scenario:
- Suppose there are no resources in the pool
- Suppose all users have maximum RC reserves
- Suppose all users spend all RC reserves and income on this resource
- Suppose all users run out of resources at time
t_drain
Then we can solve for p_0
in terms of t_drain
and the budget:
global_rc_capacity + global_rc_income * drain_time = p_0 * budget * drain_time
p_0 = (global_rc_capacity + global_rc_income * drain_time) / (budget * drain_time)
Suppose drain_time = 1 hour
. Then the interpretation of this equation is that, in an hour, users in the aggregate can only muster RC equal to their RC capacity plus an hour's worth of RC regen, call this much RC rc_1h
. If we say this RC "should" be just enough to pay for res_1h
, 1 hour's worth of a single resource (say, an hour's worth of history bytes). That implies a resource price of rc_1h / res_1h
, which is the price we set the value of p_0
to.
What about the constant B
? When x
is much smaller than B
:
- The value of
p(x)
is approximatelyA / B
- Price
p(x)
is (almost) inelastic with respect to pool sizex
- A small percentage change in
x
doesn't changep(x)
much)
When x
is much larger than B
the opposite is true:
- The value of
p(x)
is approximatelyA / x
- Price
p(x)
is (almost) elastic with respect to pool sizex
- A small percentage change in
x
causes an almost equal in magnitude percentage change inp(x)
)
So while p(x)
is never fully elastic or inelastic, you may think of B
as being near the "midpoint" of the "transition" from almost perfectly inelastic (for small x
) to almost perfectly elastic (for large x
). This makes sense, since a perfectly elastic price is desirable (when possible) but unstable when the pool goes to zero (a halving of the pool results in the doubling of the price, meaning the price "doubles infinite times" as the pool goes toward zero, "halving infinite times").
Where should this transition occur? The simple answer is a small fraction of the pool's equilibrium size at no load, say 1%
, or perhaps 1/128
.
A more rigorous way to say that p(x)
is (almost) inelastic is that, for any small value ∊
, there exists some x
small enough such that, for any small value δ
, we have f(x) / f((1+δ)*x) < 1+δ*∊
. (This can be interpreted as saying the percentage change in f(x)
in response to a percentage change in x
dies out as x →0⁺
.)
To prove this, set x = B*∊
. Then:
f(x) / f((1+δ)*x) = (A / (B+x)) / (A / (B+(1+δ)*x))
= (B+x+δ*x) / (B+x)
= 1 + δ*x / (B+x)
< 1 + δ*x / B
= 1 + δ*∊
TODO: State/prove similar condition for elasticity case.
Let τ
be the time constant for the decay rate. (The decay constant is proportional to the half-life.) The value of τ
is essentially how much time it takes for the system to "forget" about past non-usage, and places a "soft limit" on the possibility of a very long burst of very high activity being allowed as a result of "saving up" months or years worth of inactivity. The value of τ
is per-resource, and we've determined that resources should have short-term and long-term versions with different τ
values. For short-term τ
value, I recommend 1 hour. For the long-term τ
value, I recommend 15 days.
If Δt
time passes, then the exponential decay step of updating the pool should be pool -= Δt * pool / τ
.
The no-load equilibrium pool size then occurs when Δt * pool_eq / τ = Δt * budget_per_sec
, or pool_eq = τ * budget_per_sec
.