Browse Source

Randomize sidekiq-scheduler cron schedule (#4980)

SubscriptionsScheduler in particular causes high load across the
entire fediverse at 5 AM UTC every day. Randomizing cron schedules
and/or adding a random delay is considered best practice to avoid
this issue.
Patrick Figel 6 years ago
parent
commit
8811778b55
1 changed files with 7 additions and 7 deletions
  1. 7 7
      config/sidekiq.yml

+ 7 - 7
config/sidekiq.yml

@@ -7,23 +7,23 @@
   - mailers
 :schedule:
   subscriptions_scheduler:
-    cron: '0 5 * * *'
+    cron: '<%= Random.rand(0..59) %> <%= Random.rand(4..6) %> * * *'
     class: Scheduler::SubscriptionsScheduler
   media_cleanup_scheduler:
-    cron: '5 4 * * *'
+    cron: '<%= Random.rand(0..59) %> <%= Random.rand(3..5) %> * * *'
     class: Scheduler::MediaCleanupScheduler
   feed_cleanup_scheduler:
-    cron: '0 0 * * *'
+    cron: '<%= Random.rand(0..59) %> <%= Random.rand(0..2) %> * * *'
     class: Scheduler::FeedCleanupScheduler
   doorkeeper_cleanup_scheduler:
-    cron: '1 1 * * 0'
+    cron: '<%= Random.rand(0..59) %> <%= Random.rand(0..2) %> * * 0'
     class: Scheduler::DoorkeeperCleanupScheduler
   user_cleanup_scheduler:
-    cron: '4 5 * * *'
+    cron: '<%= Random.rand(0..59) %> <%= Random.rand(4..6) %> * * *'
     class: Scheduler::UserCleanupScheduler
   subscriptions_cleanup_scheduler:
-    cron: '2 2 * * 0'
+    cron: '<%= Random.rand(0..59) %> <%= Random.rand(1..3) %> * * 0'
     class: Scheduler::SubscriptionsCleanupScheduler
   ip_cleanup_scheduler:
-    cron: '0 4 * * *'
+    cron: '<%= Random.rand(0..59) %> <%= Random.rand(3..5) %> * * *'
     class: Scheduler::IpCleanupScheduler