istio: istio.io/istio/mixer/pkg/loadshedding Index | Files

package loadshedding

import "istio.io/istio/mixer/pkg/loadshedding"

Index

Package Files

evaluator.go exponentialmovingaverage.go grpclatency.go options.go ratelimit.go throttler.go

Constants

const (
    // DefaultSampleFrequency controls the base sampling rate of latency averaging calculation.
    DefaultSampleFrequency = rate.Inf
    // DefaultHalfLife controls the decay rate of an individual sample.
    DefaultHalfLife = 1 * time.Second // Impact of each sample is expected to last ~2s.
    // DefaultEnforcementThreshold controls the RPS limit under which no load shedding will occur.
    DefaultEnforcementThreshold = rate.Limit(100.0)
    // GRPCLatencyEvaluatorName is the name of the gRPC Response Latency LoadEvaluator.
    GRPCLatencyEvaluatorName = "grpcResponseLatency"
)
const (
    // RateLimitEvaluatorName is the canonical name of the RateLimitEvaluator.
    RateLimitEvaluatorName = "RateLimit"
)

func ThresholdExceeded Uses

func ThresholdExceeded(eval LoadEvaluation) bool

ThresholdExceeded determines if a load evaluation status is `ExceedsThreshold`.

type GRPCLatencyEvaluator Uses

type GRPCLatencyEvaluator struct {
    // contains filtered or unexported fields
}

GRPCLatencyEvaluator calculates the moving average of response latency (as reported via the gRPC stats.Handler interface). It then evaluates incoming requests by comparing the average response latency against a threshold.

func NewGRPCLatencyEvaluator Uses

func NewGRPCLatencyEvaluator(sampleFrequency rate.Limit, averageHalfLife time.Duration) *GRPCLatencyEvaluator

NewGRPCLatencyEvaluator creates a new LoadEvaluator that uses an average of gRPC Response Latency.

func NewGRPCLatencyEvaluatorWithThreshold Uses

func NewGRPCLatencyEvaluatorWithThreshold(sampleFrequency rate.Limit, averageHalfLife time.Duration, enforcementThreshold rate.Limit) *GRPCLatencyEvaluator

NewGRPCLatencyEvaluatorWithThreshold creates a new LoadEvaluator that uses an average of gRPC Response Latency above the specified RPS limit.

func (*GRPCLatencyEvaluator) EvaluateAgainst Uses

func (g *GRPCLatencyEvaluator) EvaluateAgainst(ri RequestInfo, threshold float64) LoadEvaluation

EvaluateAgainst implements the LoadEvaluator interface.

func (*GRPCLatencyEvaluator) HandleConn Uses

func (g *GRPCLatencyEvaluator) HandleConn(context.Context, stats.ConnStats)

HandleConn processes the Conn stats.

func (*GRPCLatencyEvaluator) HandleRPC Uses

func (g *GRPCLatencyEvaluator) HandleRPC(ctx context.Context, rs stats.RPCStats)

HandleRPC processes the RPC stats.

func (GRPCLatencyEvaluator) Name Uses

func (g GRPCLatencyEvaluator) Name() string

Name implements the LoadEvaluator interface.

func (*GRPCLatencyEvaluator) TagConn Uses

func (g *GRPCLatencyEvaluator) TagConn(ctx context.Context, cti *stats.ConnTagInfo) context.Context

TagConn can attach some information to the given context.

func (*GRPCLatencyEvaluator) TagRPC Uses

func (g *GRPCLatencyEvaluator) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context

TagRPC can attach some information to the given context.

type LoadEvaluation Uses

type LoadEvaluation struct {
    // Status indicates whether or not the threshold was exceeded.
    Status LoadStatus

    // Message enables LoadEvaluators to provide custom error messages when the threshold is
    // exceeded.
    Message string
}

LoadEvaluation holds the result of the evaluation of a current request against a threshold.

type LoadEvaluator Uses

type LoadEvaluator interface {
    // Name returns a canonical name for the LoadEvaluator.
    Name() string

    // EvaluateAgainst compares the current request and known load against the supplied
    // threshold to determine if the threshold is/will be exceeded.
    EvaluateAgainst(ri RequestInfo, threshold float64) LoadEvaluation
}

LoadEvaluator evaluates the current request against a threshold. LoadEvaluators may calculate load on an on-going basis or through some external mechanism.

type LoadStatus Uses

type LoadStatus int

LoadStatus records the determination of a LoadEvaluation.

const (
    // BelowThreshold indicates that a given request will not exceed a threshold.
    BelowThreshold LoadStatus = iota
    // ExceedsThreshold indicates that a given request will exceed a threshold.
    ExceedsThreshold
)

type Options Uses

type Options struct {
    // Mode controls the server loadshedding behavior.
    Mode ThrottlerMode

    // AverageLatencyThreshold is the threshold for response times
    // over which the server will start rejecting requests (Unavailable).
    // Providing a value for AverageLatencyThreshold will enable the gRPC
    // Latency evaluator.
    AverageLatencyThreshold time.Duration

    // SamplesPerSecond controls how often gRPC response latencies are
    // recorded for calculating the average response latency.
    SamplesPerSecond rate.Limit

    // SampleHalfLife controls the decay rate of observations of response latencies.
    SampleHalfLife time.Duration

    // LatencyEnforcementThreshold is the threshold for enforcement of response
    // latency. Above the threshold, requests will be throttled based on average
    // response latency. Below the threshold, no load-shedding will take place.
    // This provides an option for ignoring load-shedding at low request volumes
    // while preserving the protection at volume.
    LatencyEnforcementThreshold rate.Limit

    // MaxRequestsPerSecond controls the rate of requests over which the
    // server will start rejecting requests (Unavailable). Providing a value
    // for MaxRequestsPerSecond will enable the rate limit evaluator.
    //
    // In Mixer, a single Report() request may translate to multiple requests
    // counted against this limit, depending on batch size of the Report.
    MaxRequestsPerSecond rate.Limit

    // BurstSize controls the number of requests that are permitted beyond the
    // configured maximum for a period of time. This allows for handling bursty
    // traffic patterns. If this is set to 0, no traffic will be allowed.
    BurstSize int
}

Options define the set of configuration parameters for controlling loadshedding behavior.

func DefaultOptions Uses

func DefaultOptions() Options

DefaultOptions returns a new set of options, initialized to the defaults

func (*Options) AttachCobraFlags Uses

func (o *Options) AttachCobraFlags(cmd *cobra.Command)

AttachCobraFlags attaches a set of Cobra flags to the given Cobra command.

Cobra is the command-line processor that Istio uses. This command attaches the necessary set of flags to expose a CLI to let the user control all tracing options.

type RateLimitEvaluator Uses

type RateLimitEvaluator struct {
    // contains filtered or unexported fields
}

RateLimitEvaluator enforces a configured rate limit, using a rate.Limiter.

func NewRateLimitEvaluator Uses

func NewRateLimitEvaluator(limit rate.Limit, burstSize int) *RateLimitEvaluator

NewRateLimitEvaluator builds a new RateLimitEvaluator.

func (*RateLimitEvaluator) EvaluateAgainst Uses

func (r *RateLimitEvaluator) EvaluateAgainst(ri RequestInfo, threshold float64) LoadEvaluation

EvaluateAgainst implements the LoadEvaluator interface.

func (RateLimitEvaluator) Name Uses

func (r RateLimitEvaluator) Name() string

Name implements the LoadEvaluator interface.

type RequestInfo Uses

type RequestInfo struct {
    // PredictedCost enables the server to pass information about the relative
    // size (or impact) of the request into the throttler. For instance, it can
    // be used to distinguish between Check() and Report() calls by setting the
    // value to the size of the batch.
    PredictedCost float64
}

RequestInfo is used to hold information related to a request that could be relevant to a LoadEvaluator.

type Throttler Uses

type Throttler struct {
    // contains filtered or unexported fields
}

Throttler provides the loadshedding behavior by evaluating current request information against a set of configured LoadEvaluators.

func NewThrottler Uses

func NewThrottler(opts Options) *Throttler

NewThrottler builds a Throttler based on the configured options.

func (*Throttler) Evaluator Uses

func (t *Throttler) Evaluator(name string) LoadEvaluator

Evaluator returns a configured LoadEvaluator based on the supplied name. If no LoadEvaluator with the given name is known to the Throttler, a nil value will be returned.

func (*Throttler) Throttle Uses

func (t *Throttler) Throttle(ri RequestInfo) bool

Throttle returns a verdict on whether or not the server should drop the request, based on the current set of configured LoadEvaluators.

type ThrottlerMode Uses

type ThrottlerMode int

ThrottlerMode controls the behavior a throttler.

const (
    // Disabled removes all throttling behavior for the server.
    Disabled ThrottlerMode = iota
    // LogOnly enables an advisory mode for throttling behavior on the server.
    LogOnly
    // Enforce turns the throttling behavior on for the server.
    Enforce
)

Package loadshedding imports 11 packages (graph) and is imported by 4 packages. Updated 2019-09-14. Refresh now. Tools for package owners.