From b92e3fc374681d12899549991a4c85a07b03a54f Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Sun, 22 May 2022 19:35:03 -0400 Subject: [PATCH] tweak scheduler --- internal/cmd/scheduler.go | 8 ++++---- ...008_add_watcher_type_and_id_index_to_watchers.down.sql | 0 ...00008_add_watcher_type_and_id_index_to_watchers.up.sql | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 migrations/000008_add_watcher_type_and_id_index_to_watchers.down.sql create mode 100644 migrations/000008_add_watcher_type_and_id_index_to_watchers.up.sql diff --git a/internal/cmd/scheduler.go b/internal/cmd/scheduler.go index 99d3beb..931cfbb 100644 --- a/internal/cmd/scheduler.go +++ b/internal/cmd/scheduler.go @@ -86,9 +86,9 @@ func SchedulerCmd(ctx context.Context) *cobra.Command { } s := gocron.NewScheduler(time.UTC) - _, _ = s.Every(200).Milliseconds().SingletonMode().Do(func() { enqueueAccounts(ctx, logger, statsd, db, redis, luaSha, notifQueue) }) - _, _ = s.Every(200).Milliseconds().SingletonMode().Do(func() { enqueueSubreddits(ctx, logger, statsd, db, []rmq.Queue{subredditQueue, trendingQueue}) }) - _, _ = s.Every(200).Milliseconds().SingletonMode().Do(func() { enqueueUsers(ctx, logger, statsd, db, userQueue) }) + _, _ = s.Every(500).Milliseconds().SingletonMode().Do(func() { enqueueAccounts(ctx, logger, statsd, db, redis, luaSha, notifQueue) }) + _, _ = s.Every(500).Milliseconds().SingletonMode().Do(func() { enqueueSubreddits(ctx, logger, statsd, db, []rmq.Queue{subredditQueue, trendingQueue}) }) + _, _ = s.Every(500).Milliseconds().SingletonMode().Do(func() { enqueueUsers(ctx, logger, statsd, db, userQueue) }) _, _ = s.Every(1).Second().Do(func() { cleanQueues(logger, queue) }) _, _ = s.Every(1).Second().Do(func() { enqueueStuckAccounts(ctx, logger, statsd, db, stuckNotificationsQueue) }) _, _ = s.Every(1).Minute().Do(func() { reportStats(ctx, logger, statsd, db) }) @@ -444,7 +444,7 @@ func enqueueAccounts(ctx context.Context, logger *logrus.Logger, statsd *statsd. WHERE next_notification_check_at < $1 ORDER BY next_notification_check_at FOR UPDATE SKIP LOCKED - LIMIT 2500 + LIMIT 5000 ) RETURNING accounts.id` rows, err := tx.Query(ctx, stmt, now, next) diff --git a/migrations/000008_add_watcher_type_and_id_index_to_watchers.down.sql b/migrations/000008_add_watcher_type_and_id_index_to_watchers.down.sql new file mode 100644 index 0000000..e69de29 diff --git a/migrations/000008_add_watcher_type_and_id_index_to_watchers.up.sql b/migrations/000008_add_watcher_type_and_id_index_to_watchers.up.sql new file mode 100644 index 0000000..6939aaa --- /dev/null +++ b/migrations/000008_add_watcher_type_and_id_index_to_watchers.up.sql @@ -0,0 +1 @@ +CREATE INDEX watchers_type_watchee_id_idx ON watchers(type int4_ops,watchee_id int4_ops);