gateway icon indicating copy to clipboard operation
gateway copied to clipboard

add support for load balancing across multiple models and providers

Open uniAIDevs opened this issue 2 years ago • 0 comments

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, and GetProviderConfig methods within gateway/internal/api/v1/models.go and providers.go to ensure operations are performed only on healthy providers.
  • Implemented a DefaultHealthChecker struct in gateway/internal/router/health_checker.go that currently assumes all providers are healthy. This serves as a placeholder for future, more sophisticated health check logic.
  • Modified the PriorityRouter and RoundRobinRouter in gateway/internal/router/priority.go and round_robin.go to 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

uniAIDevs avatar Mar 22 '24 15:03 uniAIDevs