rto

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

rto implements adaptive timeout algorithm used in TCP retransmission timeout.

rto implements adaptive timeout algorithm used in TCP retransmission timeout.

Index

Constants

View Source
const (
	// Configurable parameters
	DEFAULT_K_MARGIN                  int64                   = 1
	DEFAULT_INTERVAL                  time.Duration           = 5 * time.Second
	DEFAULT_OVERLOAD_DETECTION_TIMING OverloadDetectionTiming = MaxTimeoutGenerated

	// Constant parameters. Alpha and Beta for Retransmission Timeout
	// Defined by  V. Jacobson, “Congestion avoidance and control,” SIGCOMM Comput.Commun.
	ALPHA_SCALING int64 = 8
	LOG2_ALPHA    int64 = 3
	BETA_SCALING  int64 = 4
	LOG2_BETA     int64 = 2

	// Tunable parameters
	// The values set for these constant leaves room for tuning
	SLO_SAFETY_MARGIN                float64 = 0.5 // safety margin of 0.5 or division by 2
	MIN_FAILED_SAMPLES               float64 = 1   // minimum failed samples reqruired to compute failure rate
	LOG2_PACING_GAIN                 int64   = 5   // used as pacing gain factor. 1+ 1 >> LOG2_PACING_GAIN
	DEFAULT_OVERLOAD_DRAIN_INTERVALS uint64  = 2   // intervals to choke rto after overload.
	DEFAULT_STARTUP_INTERVALS        uint64  = 4   // intervals to wait for the kMargin to stabilize
)

Variables

View Source
var AdaptoRTOProviders map[string]*AdaptoRTOProvider
View Source
var AdaptoRTOWCQProviders map[string]*AdaptoRTOWCQProvider
View Source
var RequestRateLimitExceeded error = requestRateLimitExceeded{}

Functions

func DefaultOnIntervalHandler added in v1.2.6

func DefaultOnIntervalHandler(AdaptoRTOProviderInterface)

func GetTimeout

func GetTimeout(ctx context.Context, config Config) (timeout time.Duration, rttCh chan<- RttSignal, err error)

GetTimeout retrieves timeout value using provider with given id in config. if no provider with matching id is found, creates a new provider

func StateAsString added in v1.3.0

func StateAsString(state RTOProviderState) string

Types

type AdaptoRTOProvider

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

func NewAdaptoRTOProvider added in v1.0.7

func NewAdaptoRTOProvider(config Config) *AdaptoRTOProvider

func (*AdaptoRTOProvider) CapacityEstimate added in v1.2.6

func (arp *AdaptoRTOProvider) CapacityEstimate() int64

CapacityEstimate returns current overload estimate If not called in onIntervalHandler, must acquire lock first

func (*AdaptoRTOProvider) ComputeNewRTO added in v1.0.7

func (arp *AdaptoRTOProvider) ComputeNewRTO(rtt time.Duration) time.Duration

ComputeNewRTO computes new rto based on new rtt new timeout value is returned and can be used to set timeouts or overload detection MUST be called in thread safe manner as it does not lock mu

func (*AdaptoRTOProvider) NewTimeout

func (arp *AdaptoRTOProvider) NewTimeout(ctx context.Context) (timeout time.Duration, rttCh chan<- RttSignal, err error)

NewTimeout returns the current timeout value pseudo client queue / rate limiting suspends timeout creation during overload

func (*AdaptoRTOProvider) OnInterval added in v1.3.0

func (arp *AdaptoRTOProvider) OnInterval()

OnInterval calculates failure rate and adjusts margin MUST be called with mu.Lock already acquired

func (*AdaptoRTOProvider) OnRtt added in v1.3.0

func (arp *AdaptoRTOProvider) OnRtt(signal RttSignal)

OnRtt handles new rtt event MUST be called in thread safe manner as it does not lock mu

func (*AdaptoRTOProvider) StartWithSLO added in v1.0.7

func (arp *AdaptoRTOProvider) StartWithSLO()

StartWithSLO starts the provider by spawning a goroutine that waits for new rtt or timeout event and updates the timeout value accordingly. timeout calculations are also adjusted to meet the SLO

func (*AdaptoRTOProvider) State added in v1.3.0

func (arp *AdaptoRTOProvider) State() string

State returns current state If not called in onIntervalHandler, must acquire lock first

type AdaptoRTOProviderInterface added in v1.3.1

type AdaptoRTOProviderInterface interface {
	NewTimeout(ctx context.Context) (timeout time.Duration, rttCh chan<- RttSignal, err error)
	CapacityEstimate() int64
	State() string
}

type AdaptoRTOWCQProvider added in v1.3.1

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

func NewAdaptoRTOWCQProvider added in v1.3.1

func NewAdaptoRTOWCQProvider(config Config) *AdaptoRTOWCQProvider

func (*AdaptoRTOWCQProvider) CapacityEstimate added in v1.3.1

func (arp *AdaptoRTOWCQProvider) CapacityEstimate() int64

CapacityEstimate returns current overload estimate If not called in onIntervalHandler, must acquire lock first

func (*AdaptoRTOWCQProvider) ComputeNewRTO added in v1.3.1

func (arp *AdaptoRTOWCQProvider) ComputeNewRTO(rtt time.Duration) time.Duration

ComputeNewRTO computes new rto based on new rtt new timeout value is returned and can be used to set timeouts or overload detection MUST be called in thread safe manner as it does not lock mu

func (*AdaptoRTOWCQProvider) NewTimeout added in v1.3.1

func (arp *AdaptoRTOWCQProvider) NewTimeout(ctx context.Context) (timeout time.Duration, rttCh chan<- RttSignal, err error)

NewTimeout returns the current timeout value pseudo client queue / rate limiting suspends timeout creation during overload

func (*AdaptoRTOWCQProvider) OnInterval added in v1.3.1

func (arp *AdaptoRTOWCQProvider) OnInterval()

OnInterval calculates failure rate and adjusts margin MUST be called with mu.Lock already acquired

func (*AdaptoRTOWCQProvider) OnRtt added in v1.3.1

func (arp *AdaptoRTOWCQProvider) OnRtt(signal RttSignal)

OnRtt handles new rtt event MUST be called in thread safe manner as it does not lock mu

func (*AdaptoRTOWCQProvider) StartWithSLO added in v1.3.1

func (arp *AdaptoRTOWCQProvider) StartWithSLO()

StartWithSLO starts the provider by spawning a goroutine that waits for new rtt or timeout event and updates the timeout value accordingly. timeout calculations are also adjusted to meet the SLO

func (*AdaptoRTOWCQProvider) State added in v1.3.1

func (arp *AdaptoRTOWCQProvider) State() string

State returns current state If not called in onIntervalHandler, must acquire lock first

type Config

type Config struct {
	Id                      string
	SLOLatency              time.Duration                    // max timeout value allowed
	Min                     time.Duration                    // min timeout value allowed
	SLOFailureRate          float64                          // target failure rate SLO
	Interval                time.Duration                    // interval for failure rate calculations
	KMargin                 int64                            // starting kMargin for with SLO and static kMargin for without SLO
	OverloadDetectionTiming OverloadDetectionTiming          // timing when to check for overload
	OverloadDrainIntervals  uint64                           // number of intervals to drain overloading requests
	OnIntervalHandler       func(AdaptoRTOProviderInterface) // handler to be called at the end of every interval
	DisableClientQueuing    bool                             //flag for feature gating client queuing

	Logger logger.Logger // optional logger
}

func (*Config) Validate added in v1.0.7

func (c *Config) Validate() *ConfigValidationError

type ConfigValidationError added in v1.1.3

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

func (ConfigValidationError) Error added in v1.1.3

func (c ConfigValidationError) Error() string

type OverloadDetectionTiming added in v1.1.4

type OverloadDetectionTiming = string
const (
	MaxTimeoutGenerated OverloadDetectionTiming = "maxTimeoutGenerated"
	MaxTimeoutExceeded  OverloadDetectionTiming = "maxTimeoutExceeded"
)

type RTOProviderState added in v1.1.0

type RTOProviderState = int64

State enum for main state machine

const (
	CRUISE RTOProviderState = iota
	STARTUP
	DRAIN
	OVERLOAD
	FAILURE
)

state transition will be STARTUP -> CRUISE -> DRAIN <-> OVERLOAD <-> FAILURE OVERLOAD -> CRUISE

type RTOWCQProviderState added in v1.3.1

type RTOWCQProviderState = int64
const (
	WCQ_CRUISE RTOWCQProviderState = iota
	WCQ_STARTUP
	WCQ_DRAIN
)

state transition will be STARTUP -> CRUISE -> DRAIN <-> OVERLOAD <-> FAILURE OVERLOAD -> CRUISE

type RttSignal

type RttSignal struct {
	Duration time.Duration
	Type     SignalType
}

RttSignal is used for reporting rtt.

type SignalType added in v1.2.0

type SignalType = int64
const (
	Successful SignalType = iota
	// GenericError should be used to signal non-timeout errors.
	// this only counts the failed but do not record rtt
	GenericError
	TimeoutError
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL