gateway
gateway copied to clipboard
add support for load balancing across multiple models and providers
Description
This pull request introduces significant enhancements to the gateway's load balancing capabilities, focusing on ensuring that operations are only directed towards healthy providers. By integrating health checks across various points where providers and models are accessed or manipulated, we ensure higher reliability and availability in serving requests. This change affects how models and providers are listed, fetched, created, updated, and how their configurations are retrieved, ensuring that only healthy entities are interacted with. Code was created by Alex Scott and Sweep AI.
Summary
- Added health check validations in
ListModels,ListProviders,GetProvider,CreateProvider,UpsertProvider, andGetProviderConfigmethods withingateway/internal/api/v1/models.goandproviders.goto ensure operations are performed only on healthy providers. - Implemented a
DefaultHealthCheckerstruct ingateway/internal/router/health_checker.gothat currently assumes all providers are healthy. This serves as a placeholder for future, more sophisticated health check logic. - Modified the
PriorityRouterandRoundRobinRouteringateway/internal/router/priority.goandround_robin.goto select the next available healthy provider, enhancing the robustness of load balancing mechanisms. - These changes collectively enhance the system's resilience by ensuring that unhealthy providers are gracefully bypassed, thereby improving the overall reliability of the service.
Files affected:
-
gateway/internal/api/v1/models.go -
gateway/internal/api/v1/providers.go -
gateway/internal/router/health_checker.go -
gateway/internal/router/priority.go -
gateway/internal/router/round_robin.go