Stability of DLedger
In this post I want to analyze the stability of Dledger, a DAG-based distributed logging system.
Brief Introduction
In Dledger, every record can refer to some existing records by putting the name of those records into its content. This is done for 2 reasons:
- Keep a causal ordering among records.
- Make the whole system be directly or indirectly referred to by a small set of records, so we can synchronize on this set.
The tailing records are the records that have not been referred to by any other record. One thing we need to confirm is that the number of tailing records is small. Therefore we need to study the stability of .
We may assume that record generation is a Poisson procedure, that is, in a unit of time the number of records each node generate have a Poisson distribution with argument . Assume the system has nodes and the number does not change. Thus, total number of records generated is a Poisson distribution of .
Since each record cannot be immediately received by another node after its generation, we assume that there is a propagation time , so a record is invisible to all nodes before this time interval, and visible to all after it.
Case 1: Refer to All
The easiest case is that each new record refers to all tailing records the node knows. Then, the number of tailing records in the system will be this record, plus all records generated in the past time. The average is .
This system is stable, since the value of at one time point is not affected by its previous value. However, if is large enough, it may be not feasible to refer to all known tailing records in a single record.
Case 2: Refer to
In this case, a new record randomly pick records from the tailing records to refer to. To simplify the calculation, we may assume that those records are sampled with replacement. We also assume that the stable value of is larger than , because otherwise it's degenerated to Case 1: .
Equilibrium
In this section, we assume the point of equilibrium is reached, and calculate its value.
Suppose a new record is generated. At this time, the new record may see tailing records. But they are really tailing only before , since some records are generated during this time, but not visible yet. There are new records generated, so by the assumption of equilibrium, there will be the same number of tailing records that are referred to and not tailing any more. Therefore, if we randomly pick a record from the records, the probability of picking a record that is still tailing is
is large, so the number of tailing records that this new record refers to is approximately . By the assumption of equilibrium, whenever we add 1 new tailing record, on average 1 tailing record should be removed. Thus, we have and
With small
To show the dynamics of , let's remove the assumption of equilibrium and take continuous approximation.
Suppose there are tailing records. Then, records are generated, each of which makes references. Therefore, if we assume that records are visible to these newly generated records, for one record, the probability of not being referred to is
Hence, the number of current tailing records will be
Omit infinitesimals of higher order (by Taylor expansion) and get the dynamic equation:
In the formula above, is always negative, which may come from the assumption that is small.
With batched generation
Here we use a different model: we don't assume is small, but records generation time is aligned with instead. That is, all records generated from will be considered as generated at . Similarly, we have
Let , which is the number of record generated after the dissemination time. Then, the condition when increase after is
Look at the left hand side. When , the 2nd term will dominate and it will be greater than 1. After that, the 1st term will dominate, which is always less than 1. So the moving tread of is
- When is less than the equilibrium point, will increase.
- When is greater than the equilibrium point, will decrease.
- As get larger, the decreasing speed will become slower. This is because as goes to infinity, we remove a fixed number of tailing records each time, which is relatively smaller compared to .
Conclusion
The number of tailing records will be stable in Dledger. The point of equilibrium is approximately proportional to the number of peers, the record generation rate, and the dissemination time. If the record generating speed is , and , then will lead to tailing records. If the speed is , we can have . This level of scalability can support a lot of applications.