Skip to content

Add SDK load balancer #138

@Kingsman-99

Description

@Kingsman-99

Label: complexity: high
Points: 200

Description

The existing round-robin distribution does not account for endpoint health or response times. This issue adds an intelligent load balancer that routes requests to the fastest healthy endpoint based on rolling latency measurements.

Technical Context

Involves a new src/loadBalancer.ts. Maintain a rolling average latency per endpoint (last 10 requests). Select the endpoint with the lowest average latency for each request. Mark endpoints as unhealthy after 3 consecutive failures. Re-probe unhealthy endpoints every 30 seconds.

Acceptance Criteria

  • LoadBalancer class exported from src/index.ts
  • Requests routed to lowest-latency healthy endpoint
  • Endpoint marked unhealthy after 3 consecutive failures
  • Unhealthy endpoint re-probed after 30 seconds
  • Test verifies faster endpoint receives more requests
  • All existing tests pass
  • TypeScript strict mode — zero any types

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions