Skip to content

feat: Proxy service integration - #4

Merged
thushan merged 13 commits into
mainfrom
feature/proxy-server-initial
May 27, 2025
Merged

thushan merged 13 commits into
mainfrom
feature/proxy-server-initial

Conversation

@thushan

@thushan thushan commented May 27, 2025

Copy link
Copy Markdown
Owner

This is the initial integration of the proxy service and load balancers based on learnings from Sherpa.

Proxy Implementation

Features

  • Streaming Proxy: Forwards requests without buffering entire payloads
  • Connection Tracking: Monitors active connections per endpoint
  • Error Handling: Automatic retry with backoff on failures
  • Health Awareness: Only routes to healthy/routable endpoints

Configuration

proxy:
  connection_timeout: 30s
  response_timeout: 900s
  max_retries: 3
  retry_backoff: 500ms
  load_balancer: "priority"

Implementation

  • Integrates with discovery service for endpoint health status
  • Preserves HTTP headers and streaming responses
  • Graceful error handling with fallback to alternative endpoints
  • Request correlation IDs for tracing
  • Configurable timeouts for different phases (connection, response, streaming)

The proxy acts as a transparent gateway, automatically selecting the best available AI endpoint for each request while maintaining compatibility with the standard Ollama / LMStudio etc API.

Load Balancer

Strategies

  • Priority: Routes to highest priority endpoints first, falls back on failure
  • Round-Robin: Distributes requests evenly across healthy endpoints
  • Least-Connections: Routes to endpoint with fewest active connections

Usage

Configure via proxy.load_balancer in config:

proxy:
  load_balancer: "priority"  # priority, round-robin, least-connections

Implementation

  • Thread-safe factory pattern for strategy selection
  • All selectors filter out unhealthy/offline endpoints automatically
  • Connection tracking for monitoring and least-connections algorithm
  • Comprehensive test coverage including concurrency and edge cases

Performance benchmarks show round-robin is fastest (~50ns), priority is well-balanced (~300ns), and least-connections works best for smaller endpoint sets (~800ns).

Strategy Latency Memory Best For
Round-Robin ~50ns 1 alloc High throughput
Priority ~300ns 4 allocs Tiered infrastructure
Least-Connections ~800ns 11 allocs Variable request duration

The least-connections will figure out better perf later. Least of our worries :D

@thushan
thushan merged commit 02c34d1 into main May 27, 2025
@thushan
thushan deleted the feature/proxy-server-initial branch May 27, 2025 08:14
EdwardHodl added a commit to EdwardHodl/olla-1 that referenced this pull request Oct 10, 2026
leo-3889 pushed a commit to leo-3889/olla that referenced this pull request Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant