Feature/SK-592 | Refactor gRPC server #490
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is a lot of redundancy in the server logic of the combiner. Also logging is messy and hard to understand, introduce logger for different verbosity . Some functions/endpoints can be merged to improve readability and reduce complexity.
Update:
gRPC endpoint Report has been removed and replaced with ListActiveClients. The combiner interfaces (interfaces.py) has list_active_clients(queue_name) which will return the number of "online" clients attached to the specific combiner. The Queue (also reffered as channel in the logic) is either MODEL_UPDATE_REQUESTS or MODEL_VALIDATION_REQUESTS.
Obeserve when the controller loadbalancer LeatPacked calls list_active_clients() it defaults to MODEL_UPDATE_REQUESTS, which means it the loadbalancer is based on the number of online "training" clients, and does not consider "validation" clients.
The way client status is managed has changed. The combiner (gRPC server) now also keeps track of the "online"/"offline" status of clients using the state dict. A client is considered online if it's gRPC context (stream) has been active for the last 10 seconds, or if the client has sent a hearbeat within 10 seconds. The status of clients are then pushed to the statestore DB, bulk update (mongodb update_many) using a deamon process, this push occur every 10 seconds. This should be made configurable in the future. It's also possible to use the gRPC endpoint ListActiveClients, this will aslo push the status updates to statestore DB once called.
The decision for this approach is: