Skip to content

Commit

Permalink
etcd_worker: use OwnerFlushInterval or ProcessorFlushInterval to calc…
Browse files Browse the repository at this point in the history
…ulate tick rate
  • Loading branch information
asddongmen authored and ti-chi-bot committed Nov 4, 2021
1 parent 50dbcfe commit c0c9ccb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/orchestrator/etcd_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ func (worker *EtcdWorker) Run(ctx context.Context, session *concurrency.Session,
sessionDone = make(chan struct{})
}
lastReceivedEventTime := time.Now()
// limit the frequency of EtcdWorker ticks
rl := rate.NewLimiter(10, 30)

// tickRate represents the number of times EtcdWorker can tick
// the reactor per second
tickRate := time.Second / timerInterval
rl := rate.NewLimiter(rate.Limit(tickRate), int(tickRate)*3)
for {
var response clientv3.WatchResponse
select {
Expand Down Expand Up @@ -185,7 +188,9 @@ func (worker *EtcdWorker) Run(ctx context.Context, session *concurrency.Session,
if err := worker.applyUpdates(); err != nil {
return errors.Trace(err)
}
// if !rl.Allow(), skip this Tick to avoid etcd worker tick too frequency

// if !rl.Allow(), skip this Tick to avoid etcd worker tick reactor too frequency
// It make etcdWorker to batch etcd changed event in worker.state
if !rl.Allow() {
continue
}
Expand Down

0 comments on commit c0c9ccb

Please sign in to comment.