• No results found

There can be negative growth rates, which lead to negative growths (for example, more decrements than increments to a value), which would mean λ being negative. How- ever, having a negative growth or a positive one, in absolute terms, is the same for diver- gence. For example, if a numeric item remotely suffers a decrement by 2, or an increment by 2, either way it is divergent by 2 until that operations applies at the replica. Therefore, the probability that the object has grown 2 or -2 is the same. So to tackle this, we simply use the absolute value of the estimated growth as parameter: λ = k = |ð|.

The second limitation is trickier, because there may be non-integer numeric values being stored in the system (for example, while the stock of an item of an online store is an integer, its price may be a decimal number), but the factorial in the formula cannot be used with non-integers. The literature usually solves this by making the Poisson distri- bution continuous, by replacing the factorial in the formula by the Gamma function of k − 1[Ili13]:

P (X = k) = λ

ke−λ

Γ(k + 1), k ∈ R+, λ > 0 (3.6)

3.4

Bounding the Divergence

To limit how divergent a replica gets, bounds are placed on the values the metrics can reach. When the metric’s value reaches that bound, coordination between that replica and the server is started. While the data center’s copy’s state may not equal the single- copy, all updates are eventually propagated to the data center, and contacting all other clients to obtain all pending updates is not feasible. Also, the data center’s divergence estimate allows the client to obtain a state that is closer to the single-copy.

As the estimate has an associated certainty degree, the bound itself may not be deter- ministically guaranteed, since the estimate is used to enforce it. Because of this, when the bound is set, the degree of confidence with which the bound is assured must also be set. The higher this degree, the less probable it is that the bound has been broken, but there will be forced coordination more often, especially for low divergence bounds, when coor- dination already happens more frequently. In contrast, for higher bounds, coordination will be scarcer, so a higher confidence degree will increase coordination mostly when the bound is close to being broken.

Too bound the client’s divergence under a certain limit, lim, we resort to the estimated divergence of the single-copy, ð. Put simply, if the single-copy’s state diverged more than lim, then the bound is broken. As such, we want to guarantee that, with confidence ζlim,

the single-copy’s growth was less than or equal to lim.

The confidence level ζ, that ð is below or equal to lim, is the sum of the certainty degrees of all values between 0 and lim. This is because the probability of ð ≤ lim is the probability of the single-copy having not diverged at all (that is, having diverged 0), or

3. ESTIMATING ANDBOUNDING THEDIVERGENCE 3.4. Bounding the Divergence

having diverged in any value up to, and including lim. Therefore:

ζ = P (X ≤ k) =

lim

X

k=0

P (X = k), k ∈ N+ (3.7)

If ζ ≥ ζlim, then the bound is estimated to be kept.

3.4.1 Bounding With the Rhythmic Model

With our model, to estimate if the bound is kept with confidence level ζ, one must only calculate P (X ≤ k) using the Poisson distribution. This is made by simply using expres- sion 3.5 to obtain P (X = k) inside the sum in equation 3.7.

This is valid for the value metric for integer objects, and for the operations metric, since both of these metrics’ values are integers (there are no “half” operations). In the case of the value metric for a non-integer number, there are infinite values of divergence between 0 and lim. As such, instead of a summation, ζ is calculated using an integral. This alters expression 3.7 to:

ζ = P (X ≤ k) = Z lim

0

P (X = k) dk, k ∈ R+ (3.8)

where P must be calculated using the Gamma-function-based expression, as seen in equation 3.6.

3.4.2 Preserving Integrity Constraints

To guarantee that an integrity constraint is kept, we must assure that the single-copy has not diverged to a state where the integrity constraint is not kept. To this end, it is necessary to define the maximum possible growth the single-copy can achieve without breaking the invariant, ðinv. Keeping this in mind, this problem is reduced to checking if

a divergence bound of ðinvis kept with a certain degree of confidence, ζinv, as seen in the

previous section. If that bound has not been broken, then the single-copy is preserving that integrity constraint.

Assuming the rhythmic model is used, let’s consider the example of the online store, adding the constraint that an item’s stock may not reach negative values. This constraint is of utmost importance for the store, since a client cannot purchase an item that the store cannot deliver, so the degree of confidence of this estimate must be high, let’s assume 95% (so ζinv = 0.95). A client saw 3 seconds ago that a certain item’s stock was 10, with

a growth rate of -1 per second (so λ = k = |ð| = | − 1 × 3| = 3). In this case, ðinv = 10,

since the maximum the stock could be decremented without breaking the invariant is 10, reaching a stock of 0, but not a negative one. To certify this, we must calculate the degree of confidence, ζ, that assures ð ≤ ðinv. Using expression 3.7 with lim = 10 and

λ = k = 3, we obtain ζ = 0.9997. Since ζ ≥ ζinv, the integrity constraint is kept with the

Related documents