File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -764,10 +764,16 @@ class PerAccountStore extends PerAccountStoreBase with
764764 // so as to fully pick up the new server's features.
765765
766766 if (_postRestartTimer != null ) return ;
767+ // Spread the reload out randomly in time, to avoid a thundering herd
768+ // of clients hitting the server with reload requests.
767769 const minWaitMs = 1 * Duration .millisecondsPerMinute;
768770 const maxWaitMs = 1 * Duration .millisecondsPerHour;
771+ // The random spread should cover at least 5 minutes;
772+ // see https://zulip.com/api/get-events#restart .
773+ assert (maxWaitMs - minWaitMs >= 5 * Duration .millisecondsPerMinute);
769774 final waitMs = minWaitMs + Random ().nextInt (maxWaitMs - minWaitMs + 1 );
770775 final waitDuration = Duration (milliseconds: waitMs);
776+
771777 _postRestartTimer = Timer (waitDuration, _postRestart);
772778 }
773779
You can’t perform that action at this time.
0 commit comments