summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorasomers <asomers@FreeBSD.org>2017-04-24 15:29:17 +0000
committerasomers <asomers@FreeBSD.org>2017-04-24 15:29:17 +0000
commit3c8d119ce1db45d1f054bb3c1bfa71d993fafc94 (patch)
tree114f99bdc9a1aaf5359b25439e078281827cb20d /etc
parent45105004da0b6dd9f5da6cee0872480d6bf94446 (diff)
downloadFreeBSD-src-3c8d119ce1db45d1f054bb3c1bfa71d993fafc94.zip
FreeBSD-src-3c8d119ce1db45d1f054bb3c1bfa71d993fafc94.tar.gz
MFC r316342, r316358
r316342: Consolidate random sleeps in periodic scripts Multiple periodic scripts sleep for a random amount of time in order to mitigate the thundering herd problem. This is bad, because the sum of multiple uniformly distributed random variables approaches a normal distribution, so the problem isn't mitigated as effectively as it would be with a single sleep. This change creates a single configurable anticongestion sleep. periodic will only sleep if at least one script requires it, and it will never sleep more than once per invocation. It also won't sleep if periodic was run interactively, fixing an unrelated longstanding bug. PR: 217055 PR: 210188 Reviewed by: cy MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D10211 r316358: Fix man page typo from r316342 Reported by: rgrimes MFC after: 20 days X-MFC-With: 316342
Diffstat (limited to 'etc')
-rw-r--r--etc/defaults/periodic.conf16
-rwxr-xr-xetc/periodic/daily/480.leapfile-ntpd13
2 files changed, 17 insertions, 12 deletions
diff --git a/etc/defaults/periodic.conf b/etc/defaults/periodic.conf
index 16de38e..b3be114 100644
--- a/etc/defaults/periodic.conf
+++ b/etc/defaults/periodic.conf
@@ -22,6 +22,8 @@ periodic_conf_files="/etc/periodic.conf /etc/periodic.conf.local"
# periodic script dirs
local_periodic="/usr/local/etc/periodic"
+# Max time to sleep to avoid causing congestion on download servers
+anticongestion_sleeptime=3600
# Daily options
@@ -136,8 +138,6 @@ daily_status_mail_rejects_shorten="NO" # Shorten output
# 480.leapfile-ntpd
daily_ntpd_leapfile_enable="YES" # Fetch NTP leapfile
-daily_ntpd_avoid_congestion="YES" # Avoid congesting
- # leapfile sources
# 480.status-ntpd
daily_status_ntpd_enable="NO" # Check NTP status
@@ -307,6 +307,18 @@ security_status_tcpwrap_period="daily"
if [ -z "${source_periodic_confs_defined}" ]; then
source_periodic_confs_defined=yes
+ # Sleep for a random amount of time in order to mitigate the thundering
+ # herd problem of multiple hosts running periodic simultaneously.
+ # Will not sleep when used interactively.
+ # Will sleep at most once per invocation of periodic
+ anticongestion() {
+ [ -n "$PERIODIC_IS_INTERACTIVE" ] && return
+ if [ -f "$PERIODIC_ANTICONGESTION_FILE" ]; then
+ rm -f $PERIODIC_ANTICONGESTION_FILE
+ sleep `jot -r 1 0 ${anticongestion_sleeptime}`
+ fi
+ }
+
# Compatibility with old daily variable names.
# They can be removed in stable/11.
security_daily_compat_var() {
diff --git a/etc/periodic/daily/480.leapfile-ntpd b/etc/periodic/daily/480.leapfile-ntpd
index 8a38364..6b2a1f3 100755
--- a/etc/periodic/daily/480.leapfile-ntpd
+++ b/etc/periodic/daily/480.leapfile-ntpd
@@ -13,16 +13,9 @@ fi
case "$daily_ntpd_leapfile_enable" in
[Yy][Ee][Ss])
- case "$daily_ntpd_avoid_congestion" in
- [Yy][Ee][Ss])
- # Avoid dogpiling
- (sleep $(jot -r 1 0 3600); service ntpd onefetch) &
- ;;
- *)
- service ntpd onefetch
- ;;
- esac
- ;;
+ anticongestion
+ service ntpd onefetch
+ ;;
esac
exit $rc
OpenPOWER on IntegriCloud