Load balancing
Load balancing is a method used to distribute incoming requests across multiple instances of the same model. It can be used to improve performance of the system by distributing the load or by the selection of the model with the best performance. Load balancing can be configured globally for all model groups:
or for a specific model group:
Round Robin load balancing
Round Robin is a simple load balancing strategy, where the requests are distributed evenly across all models in the group. Requests are distributed in a cycle, where each model is selected once per cycle. This strategy is useful when all models have the similar performance and you want to distribute the load evenly.
When some model is unavailable, the load balancer will skip it and continue with the next model in the cycle.
Multi-arm bandit based load balancing
Multi-arm bandit-based load balancing strategies are used to select the best model based on the performance of the models in the group. The load balancer keeps track of the performance of each model and uses this information to select the best model for the next request. This strategy contains two phases: exploration and exploitation. In the exploration phase, the load balancer tries to assess the performance of each model in the group. Exploitation then uses the information gathered from exploration to select the best target model for the next request.
Epsilon greedy
Epsilon greedy is a simple implementation of the multi-arm bandit load balancing strategy. In the exploration phase, the load balancer selects a random model from the group and sends the request to it. The exploitation phase then selects the model with the best performance based on the exploration phase. The epsilon parameter defines the probability of the exploration phase in each request. The higher the epsilon, the more often the load balancer will explore the models in the group.
Health check
Health check works similarly to the epsilon greedy strategy, but the exploration phase is handled by the health check. The health check periodically sends requests to all models in the group and evaluates the performance of each model. The load balancer then only sends requests to the models with the best performance.
Example of the health check load balancing strategy:
Sweden model returns best performance, so the load balancer will send the next request to this model.
Priorities
Priorities allow you to prefer certain models over others in the selected group. When a user sends a request to the group, models with the highest priority are chosen to process the request. If all models with the highest priority are inaccessible, then the request is sent to models with a lower priority. A lower number means higher priority. If two models have the same priority, the gateway will choose one based on the configured load balancing strategy. Priority can be any positive integer. By default, all models have their priority set to 50. Priorities can be used in many ways, for example, to prefer geographically closer models or to prefer PTU instances over non-PTU instances.
Usage example - PTU
Prioritize single instance of model endpoint with PTU over model endpoints without PTU. Call non-PTU instances only when PTU instance is not available.
Non-PTU instances don’t have a set priority, so they have a default priority of 50.
Usage example - prefer geographically closer models
Prioritize models based on their location. Call the closest models first, and if they are not available, call the other ones.