Exponential backoff expression (buffer)
I saw that the buffer page https://github.com/fluent/fluentd-docs-gitbook/blob/1.0/configuration/buffer-section.md said that the following expression is used for exponential backoff:
c + c * b^1 + (...) + c*b^k = c*b^(k+1) - 1
It doesn't seem right to me. For example, if c=2, the number at the left is even and the one at the right is odd.
If you try to simplify b^0 + b^1 + ... + b^k (let's call x), you could do:
x=b^0 + b^1 + ... + b^k
b*x - x = (b^1 + b^2 + ... + b^(k+1)) - (b^0 + b^1 + ... + b^k)
(b - 1) * x = b^(k+1) - b^0
x = (b^(k+1) - 1)/(b-1)
so the correct expression should be c*(b^(k+1) - 1)/(b-1), isn't it?
Considering the following expressions:
[1] b^0 + b^1 + ... + b^k [original]
[2] c*b^(k+1) - 1 [the one in the docs]
[3] c*(b^(k+1) - 1)/(b-1) [the new one]
If you use some random numbers to test some cases for:
c=1
b=2
k=3
[1] 1*2^0 + 1*2^1 + 1*2^2 + 1*2^3 = 1 + 2 + 4 + 8 = 15
[2] 1*2^(3+1) - 1 = 2^4 - 1 = 15
[3] 1*((2^(3+1) - 1)/(2 - 1)) = 2^4 - 1 = 16-1 = 15
in the above case it's the same value, but:
c=2
b=3
k=4
[1] 2*3^0 + 2*3^1 + 2*3^2 + 2*3^3 + 2*3^4 = 2 + 6 + 18 + 54 + 162 = 242
[2] 2*3^(4+1) - 1 = 2*3^5 - 1 = 2*243 - 1 = 485
[3] 2*((3^(4+1) - 1)/(3-1)) = 2*((243 - 1)/2) = 242
in this case the expression in the docs is wrong (unless I made some huge mistake, but I don't think so).
That said, the expression in the docs c*b^(k+1) - 1 increases exponentially as the number of retries increase, so it should be ok to use this expression, but I think that in this case it should be better to remove the expression in the left and let just this expression in the docs (this way there is no need to change the code used in the application, just the docs).
Just my 2 cents :)