richardartoul / nola

MIT License
74 stars 6 forks source link

Replication #69

Closed aratz-lasa closed 1 year ago

aratz-lasa commented 1 year ago

Pull Request Description:

This pull request implements actor replication in the NOLA system. The main goal is to ensure actors' availability and load balancing by replicating them across multiple servers. The code diff includes the following changes:

  1. Refactored the EnsureActivation method in the kvRegistry struct to improve readability and maintainability.
  2. Refactored the helper function pickServersForActivation to select multiple servers, instead of a single one, for actor activation based on various criteria such as memory usage, activation count, blacklisting, and caching.
  3. Updated the comments to explain the replication logic and code behavior clearer.
  4. Added the pickServersForActivation function to randomly choose the servers for actor activation.
  5. Added the ExtraReplicas field to the EnsureActivationRequest struct. This field specifies the desired number of additional replicas to be created during actor activation in addition to the primary replica.
  6. Moved the ExtraReplicas field from the ActorOptions struct to the EnsureActivationRequest struct. This change aligns the field with its usage in the EnsureActivation method and ensures consistency in the codebase.

Additionally, the code changes include improvements to handle server blacklisting in the ensureActivation method. The logic ensures that if the current request specifies blacklisted servers and any of those servers are not marked as blacklisted in the cache, the cache is refreshed to prevent routing back to blacklisted server IDs. The code also filters the cached references to exclude blacklisted servers for subsequent processing.

Most interesting files to review:

richardartoul commented 1 year ago

Fixing nits here: https://github.com/richardartoul/nola/pull/77/files