In[]:=
railsLog[attempt_,pollInterval_,maxDelay_]:=Module[{fun},fun=Function[{a,s,mx},m:=5;i:=m*Log[a+1.0];d:=Min[Max[s,i],mx];If[a===0,d,fun[a-1,s,mx]+d]];fun[attempt,pollInterval,maxDelay]]
In[]:=
railsBackoff[attempt_,pollInterval_,backoffRate_,maxDelay_]:=Module[{fun},fun=Function[{a,p,br,mx},r:=Random[Real,1.0];b:=(1+br)^(Min[a,10]);j:=If[a>0,br,1.0];j=j*r;d:=Min[p*b*(1+j),mx];If[a===0,d,d+fun[a-1,p,br,mx]]];fun[attempt,pollInterval*2,backoffRate,maxDelay]]
In[]:=
loguxDelay[attempt_,minDelay_,maxDelay_]:=Module[{fun},fun=Function[{a,md,mx},b:=md*(2^a);r:=Random[Real,1.0];dv:=r*0.5*b;dv=If[Floor[r*10]==1.0,-dv,dv]; d:=Max[Min[b+dv,mx],0];If[a===1,d,fun[a-1,md,mx]+d]];fun[attempt+1,minDelay,maxDelay]]
In[]:=
anyBackoff[attempt_,minDelay_,backoffRate_,jitterRatio_,maxDelay_]:=Module[{fun},fun=Function[{a,md,br,jr,mx},left:=2*md*(br^a);right:=2*md*(br^(a+1));t:=Min[mx,left+(right-left)*Random[Real,1.0]];dv:=2*(Random[Real,1.0]-0.5)*jr;d:=t*(1+dv);If[a===0,d,fun[a-1,md,br,jr,mx]+d]];fun[attempt,minDelay,backoffRate,jitterRatio,maxDelay]]
Manipulate[Column[{Row[{Column[{Style["Rails 6 (log)",Bold],Histogram[Table[railsLog[a,p,mx],{x,n}],{0,mx+5,1},ChartStyle{RGBColor["#ff5e5e"]},ColorFunctionScalingFalse,ImageSize{400,250},PlotRange{Automatic,n}]}],Column[{Style["Rails 7 (backoff)",Bold],Histogram[Table[railsBackoff[a,p,b,mx],{x,n}],{0,mx+5,1},ChartStyle{Red},ColorFunctionScalingFalse,ImageSize{400,250},PlotRange{Automatic,n}]}]}],Row[{Column[{Style["Logux",Bold],Histogram[Table[loguxDelay[a,p,mx],{x,n}],{0,mx+5,1},ChartStyle{RGBColor["#f5a623"]},ColorFunctionScalingFalse,ImageSize{400,250},PlotRange{Automatic,n}]}],Column[{Style["AnyCable",Bold],Histogram[Table[anyBackoff[a,p,b+1,j,mx],{x,n}],{0,mx+5,1},ChartStyle{Green},ColorFunctionScalingFalse,ImageSize{400,250},PlotRange{Automatic,n}]}]}]}],{{p,3,"Poll interval / Min delay"},1,20,1},{{b,1.15,"Backoff rate"},1.0,2.1,0.15},{{n,100,"Number of clients"},100,1000,100},{{mx,30,"Max delay"},5,120,5},{{a,0,"Reconnects attempted"},0,5,1},{{j,0.5,"Jitter ratio"},0,1,0.1}]
Out[]=