Skip to content

Commit

Permalink
Spread the sync load over time (grafana#1587)
Browse files Browse the repository at this point in the history
* Spread the sync load over time

Signed-off-by: Goutham Veeramachaneni <[email protected]>

* Move seed to main

Signed-off-by: Goutham Veeramachaneni <[email protected]>
  • Loading branch information
gouthamve authored Aug 22, 2019
1 parent 271a9cb commit f919fd8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions table_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"flag"
"fmt"
"math/rand"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -166,6 +167,9 @@ func (m *TableManager) Stop() {
func (m *TableManager) loop() {
defer m.wait.Done()

// Sleep for a bit to spread the sync load across different times if the tablemanagers are all started at once.
time.Sleep(time.Duration(rand.Int63n(int64(m.cfg.DynamoDBPollInterval))))

ticker := time.NewTicker(m.cfg.DynamoDBPollInterval)
defer ticker.Stop()

Expand Down

0 comments on commit f919fd8

Please sign in to comment.