Netflix / ribbon

Ribbon is a Inter Process Communication (remote procedure calls) library with built in software load balancers. The primary usage model involves REST calls with various serialization scheme support.
Apache License 2.0
4.58k stars 1.24k forks source link

Technical Debt: Cyclic dependency between LoadBalanceStats and ServerStats #470

Open jbpextra opened 3 years ago

jbpextra commented 3 years ago

As explained in #465 , a cyclic dependency between LoadBalancerStats and ServerStats has created a persistent negative impact on developers when working in these classes. We have computed this negative impact to be as high as 12% in some commits, with a persistent effect of an average 4.5%

Specifically, these classes are very tightly coupled by their shared dynamic configuration attributes. The UnboxedIntProperty attributes of both this classes are reference to the same objects. This makes the source code more difficult to maintain and therefore these needs to be encapsulated in its own abstraction. image

Changes:

We introduce a new class called ConfigStats that encapsulate these attributes. Its associated methods others have been moved from LoadBalancer to this new class. Instances of both LoadBalancer and ServerStats own a ConfigStats object which they use to access the now encapsulated UnboxedIntProperty using primitive getter/setters. Thus, the underlying dynamic configuration logic is effectively abstracted away and the cyclic dependency is dissolved. image

jbpextra commented 3 years ago

Hi @carl-mastrangelo , could you have a look at the pull request? Thanks!