about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-08-19 03:50:34 +0200
committerGitHub <noreply@github.com>2018-08-19 03:50:34 +0200
commit59c68c1a74d5398b9c31489744ff8eca82e2ce50 (patch)
treeea2ceb0ac89b4976d8b4f9a0529995aaffd652e5
parent19b07ba260a64b300a81890119af0970df0eb994 (diff)
Reduce user active duration from 7 days to 2 days (#8282)
To minimize fanout work and redis home feed storage space when
there are lots of recent sign-ups
-rw-r--r--app/models/user.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index c820c553a..a2cf2565f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -42,7 +42,14 @@ class User < ApplicationRecord
   include Settings::Extend
   include Omniauthable
 
-  ACTIVE_DURATION = 7.days
+  # The home and list feeds will be stored in Redis for this amount
+  # of time, and status fan-out to followers will include only people
+  # within this time frame. Lowering the duration may improve performance
+  # if lots of people sign up, but not a lot of them check their feed
+  # every day. Raising the duration reduces the amount of expensive
+  # RegenerationWorker jobs that need to be run when those people come
+  # to check their feed
+  ACTIVE_DURATION = ENV.fetch('USER_ACTIVE_DAYS', 7).to_i.days
 
   devise :two_factor_authenticatable,
          otp_secret_encryption_key: Rails.configuration.x.otp_secret