diff --git a/go/vt/vttablet/tabletserver/throttle/mysql/mysql_throttle_metric.go b/go/vt/vttablet/tabletserver/throttle/mysql/mysql_throttle_metric.go index 68e3e628f39..fd738b1f08f 100644 --- a/go/vt/vttablet/tabletserver/throttle/mysql/mysql_throttle_metric.go +++ b/go/vt/vttablet/tabletserver/throttle/mysql/mysql_throttle_metric.go @@ -31,7 +31,7 @@ const ( MetricsQueryTypeUnknown ) -var mysqlMetricCache = cache.New(cache.NoExpiration, 10*time.Millisecond) +var mysqlMetricCache = cache.New(cache.NoExpiration, 10*time.Second) func getMySQLMetricCacheKey(probe *Probe) string { return fmt.Sprintf("%s:%s", probe.Key, probe.MetricQuery) diff --git a/go/vt/vttablet/tabletserver/throttle/throttler.go b/go/vt/vttablet/tabletserver/throttle/throttler.go index bba74204b42..755ca97b84b 100644 --- a/go/vt/vttablet/tabletserver/throttle/throttler.go +++ b/go/vt/vttablet/tabletserver/throttle/throttler.go @@ -44,12 +44,12 @@ const ( mysqlAggregateInterval = 100 * time.Millisecond aggregatedMetricsExpiration = 5 * time.Second - aggregatedMetricsCleanup = 1 * time.Second + aggregatedMetricsCleanup = 10 * time.Second throttledAppsSnapshotInterval = 5 * time.Second recentAppsExpiration = time.Hour * 24 nonDeprioritizedAppMapExpiration = time.Second - nonDeprioritizedAppMapInterval = 100 * time.Millisecond + nonDeprioritizedAppMapInterval = 10 * time.Second dormantPeriod = time.Minute defaultThrottleTTLMinutes = 60 @@ -165,34 +165,34 @@ func NewThrottler(env tabletenv.Env, ts *topo.Server, tabletTypeFunc func() topo Size: 2, IdleTimeoutSeconds: env.Config().OltpReadPool.IdleTimeoutSeconds, }), + } - mysqlThrottleMetricChan: make(chan *mysql.MySQLThrottleMetric), - - mysqlInventoryChan: make(chan *mysql.Inventory, 1), - mysqlClusterProbesChan: make(chan *mysql.ClusterProbes), - mysqlInventory: mysql.NewInventory(), + if env.Config().EnableLagThrottler { + throttler.mysqlThrottleMetricChan = make(chan *mysql.MySQLThrottleMetric) - metricsQuery: replicationLagQuery, - MetricsThreshold: sync2.NewAtomicFloat64(throttleThreshold.Seconds()), + throttler.mysqlInventoryChan = make(chan *mysql.Inventory, 1) + throttler.mysqlClusterProbesChan = make(chan *mysql.ClusterProbes) + throttler.mysqlInventory = mysql.NewInventory() - throttledApps: cache.New(cache.NoExpiration, 10*time.Second), - mysqlClusterThresholds: cache.New(cache.NoExpiration, 0), - aggregatedMetrics: cache.New(aggregatedMetricsExpiration, aggregatedMetricsCleanup), - recentApps: cache.New(recentAppsExpiration, time.Minute), - metricsHealth: cache.New(cache.NoExpiration, 0), + throttler.metricsQuery = replicationLagQuery + throttler.MetricsThreshold = sync2.NewAtomicFloat64(throttleThreshold.Seconds()) - tickers: [](*timer.SuspendableTicker){}, + throttler.throttledApps = cache.New(cache.NoExpiration, 10*time.Second) + throttler.mysqlClusterThresholds = cache.New(cache.NoExpiration, 0) + throttler.aggregatedMetrics = cache.New(aggregatedMetricsExpiration, aggregatedMetricsCleanup) + throttler.recentApps = cache.New(recentAppsExpiration, time.Minute) + throttler.metricsHealth = cache.New(cache.NoExpiration, 0) - nonLowPriorityAppRequestsThrottled: cache.New(nonDeprioritizedAppMapExpiration, nonDeprioritizedAppMapInterval), + throttler.tickers = [](*timer.SuspendableTicker){} + throttler.nonLowPriorityAppRequestsThrottled = cache.New(nonDeprioritizedAppMapExpiration, nonDeprioritizedAppMapInterval) - httpClient: base.SetupHTTPClient(0), + throttler.httpClient = base.SetupHTTPClient(0) + throttler.initThrottleTabletTypes() + throttler.ThrottleApp("abusing-app", time.Now().Add(time.Hour*24*365*10), defaultThrottleRatio) + throttler.check = NewThrottlerCheck(throttler) + throttler.initConfig("") + throttler.check.SelfChecks(context.Background()) } - throttler.initThrottleTabletTypes() - throttler.ThrottleApp("abusing-app", time.Now().Add(time.Hour*24*365*10), defaultThrottleRatio) - throttler.check = NewThrottlerCheck(throttler) - throttler.initConfig("") - throttler.check.SelfChecks(context.Background()) - return throttler }