Skip to content

Move the current `LoadBalancing` code using a single database to CE

Executive Summary

Currently, this is very complex to write a code being loadbalancing-aware. This results in a number of EE-specific overwrites to support application-level support for load balancing to ensure that application is replica-aware.

Proposal

We should move majority of this code to FOSS, or ensure that it is implemented in a generic way using a well established pattern of Rails 6.

This becomes essential to be able to ensure that we can reduce code complexity of supporting many flavours of database access patterns in a application, especially in a context of a proposed application sharding: #327881 (closed).

Relation to paid feature

Since this is currently a paid feature:

  • we might decide to make the paid feature available in Core (preferred)
  • devise a way to move a majority of code changes making application replica aware to FOSS without exposing a support for many load balancing connections (harder). In fact introducing stubs instead of the implementation

Approved: #327902 (comment 571134357)

Confidence level 80%

Ref.: https://docs.gitlab.com/ee/administration/postgresql/replication_and_failover.html

Approach

  1. Move the core library files from EE to Core => !60894 (merged)
  2. Investigate each occurrence of LoadBalancing in ee/**/ee to make sure that features still work in Core if Load Balancing is enabled in Core. => !62636 (closed)
  3. Remove ENABLE_LOAD_BALANCING_FOR_FOSS to enable DB Load Balancing feature in Core by default

Impact to developers

  1. Now that !60894 (merged) is merged, do not implement new override EE methods just to call LoadBalancing. Simply call it from the core code.
  2. If the feature is EE only, then call it from the EE code as usual
  3. For existing overridden methods that call LoadBalancing, it is being moved one by one. See #related-merge-requests for list.
Edited by Thong Kuah