Documentation
¶
Overview ¶
rto implements adaptive timeout algorithm used in TCP retransmission timeout.
Index ¶
Constants ¶
const ( DEFAULT_BACKOFF int64 = 2 CONSERVATIVE_BACKOFF int64 = 1 DEFAULT_K_MARGIN int64 = 1 DEFAULT_INTERVAL time.Duration = 5 * time.Second DEFAULT_SLO float64 = 0.1 ALPHA_SCALING int64 = 8 LOG2_ALPHA int64 = 3 BETA_SCALING int64 = 4 LOG2_BETA int64 = 2 SLO_SAFETY_MARGIN float64 = 0.5 // safety margin of 0.5 or division by 2 MIN_FAILED_SAMPLES float64 = 2 )
Variables ¶
var AdaptoRTOProviders map[string]*AdaptoRTOProvider
Functions ¶
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) ChokeTimeout ¶ added in v1.1.0
func (arp *AdaptoRTOProvider) ChokeTimeout()
ChokeTimeout handles timeout update when transitioning to overload should lock rto updates
func (*AdaptoRTOProvider) ComputeNewRTO ¶ added in v1.0.7
func (arp *AdaptoRTOProvider) ComputeNewRTO(rtt time.Duration)
ComputeNewRTO computes new rto based on new rtt MUST be called in thread safe manner as it does not lock mu
func (*AdaptoRTOProvider) CurrentReq ¶ added in v1.1.1
func (arp *AdaptoRTOProvider) CurrentReq() int64
CurrentReq extraporates current number of requests for the past interval using sliding window this should be used when overload is declared ref: https://blog.cloudflare.com/counting-things-a-lot-of-different-things/ should lock rto updates
func (*AdaptoRTOProvider) NewTimeout ¶
func (arp *AdaptoRTOProvider) NewTimeout() (timeout time.Duration, rttCh chan<- RttSignal)
NewTimeout returns the current timeout value TODO: currently, timeouts are adjusted for every response and every capacity * interval requests. this means that the timeout cannot quickly adjuste to the sudden increase in requests until they return. consider adjusting the timeout value based on the current inflight could possibly use X = inflight / requestLimt higher the X, it is close to being overloaded
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
type Config ¶
type Config struct { Id string Max 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 Logger logger.Logger // optional logger }
type RTOProviderState ¶ added in v1.1.0
type RTOProviderState = int64
State enum for main state machine
const ( NORMAL RTOProviderState = iota OVERLOAD )