From f919fd84d795d0c8075321886a1aa8a09d7169f9 Mon Sep 17 00:00:00 2001 From: Goutham Veeramachaneni Date: Thu, 22 Aug 2019 15:07:56 +0530 Subject: [PATCH] Spread the sync load over time (#1587) * Spread the sync load over time Signed-off-by: Goutham Veeramachaneni * Move seed to main Signed-off-by: Goutham Veeramachaneni --- table_manager.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/table_manager.go b/table_manager.go index 3f9d8b6269dc..27865b7c5791 100644 --- a/table_manager.go +++ b/table_manager.go @@ -5,6 +5,7 @@ import ( "errors" "flag" "fmt" + "math/rand" "sort" "strings" "sync" @@ -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()