Skip to content

Commit

Permalink
add a counter for endpoints that opted out before loadbalancing
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa Abdelrahman <[email protected]>
  • Loading branch information
MustafaSaber committed Apr 23, 2024
1 parent 2330b75 commit 06ac702
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/operation/operation.md
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,12 @@ The parameters of `-passive-health-check` option are:
+ `max-drop-probabilty=<float more than/equal to 0 and less than/equal to 1>` - the maximum possible probability of unhealthy endpoint being not considered
while choosing the endpoint for the given request

### Metrics

A set of metrics will be exposed to track passive health checks:

* `routing.endpoint.drop.loadbalancer`: Number of endpoints dropped before load balancing the requests

## Memory consumption

While Skipper is generally not memory bound, some features may require
Expand Down
4 changes: 3 additions & 1 deletion proxy/healthy_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package proxy
import (
"math/rand"

"github.com/zalando/skipper/metrics"
"github.com/zalando/skipper/routing"
)

Expand All @@ -11,7 +12,7 @@ type healthyEndpoints struct {
endpointRegistry *routing.EndpointRegistry
}

func (h *healthyEndpoints) filterHealthyEndpoints(endpoints []routing.LBEndpoint, rt *routing.Route) []routing.LBEndpoint {
func (h *healthyEndpoints) filterHealthyEndpoints(endpoints []routing.LBEndpoint, metrics metrics.Metrics) []routing.LBEndpoint {
if h == nil {
return endpoints
}
Expand All @@ -22,6 +23,7 @@ func (h *healthyEndpoints) filterHealthyEndpoints(endpoints []routing.LBEndpoint
for _, e := range endpoints {
if p < e.Metrics.HealthCheckDropProbability() {
/* drop */
metrics.IncCounter("routing.endpoint.drop.loadbalancer")
} else {
filtered = append(filtered, e)
}
Expand Down
2 changes: 1 addition & 1 deletion proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ func (p *Proxy) selectEndpoint(ctx *context) *routing.LBEndpoint {
rt := ctx.route
endpoints := rt.LBEndpoints
endpoints = p.fadein.filterFadeIn(endpoints, rt)
endpoints = p.heathlyEndpoints.filterHealthyEndpoints(endpoints, rt)
endpoints = p.heathlyEndpoints.filterHealthyEndpoints(endpoints, p.metrics)

lbctx := &routing.LBContext{
Request: ctx.request,
Expand Down

0 comments on commit 06ac702

Please sign in to comment.