Always enable the database load balancing code
In #331776 (closed) / !67773 (merged) we are working towards adding support for multiple databases in our load balancer.
A problem we are running into is that in various places we check, at runtime, if the load balancer is enabled. If so, we perform extra work. This introduces two problems:
- It depends on global state (
LoadBalancing.enable?
and the data/methods it uses). In some places we can't refactor this without the use of global state. - It introduces two code paths: one where the load balancer is enabled, and one where it isn't.
These two problems are currently blocking !67773 (merged), as we can't really continue unless we get rid of this.
To tackle this, I propose that we always enable the load balancing code (e.g.
the proxies). We can then remove the various if LoadBalancing.enable?
checks.
This does require that we make a change to our load balancing logic: currently the load balancer assumes there's always one replica. If we enable the load balancing logic by default, this won't be the case for many users. As such we need to do the following: when no replicas are configured, we always use the primary/read-write connection.