From 8ba338640f31513d9c93f3b6d91d84e6768046cf Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 12 Dec 2022 20:21:06 -0700 Subject: [PATCH 1/2] Update FederationController, add two new queues (follow, shared) to prioritize follow request handling --- app/Http/Controllers/FederationController.php | 12 ++++++++---- config/horizon.php | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/FederationController.php b/app/Http/Controllers/FederationController.php index da4e5c37e..245298d29 100644 --- a/app/Http/Controllers/FederationController.php +++ b/app/Http/Controllers/FederationController.php @@ -166,17 +166,19 @@ class FederationController extends Controller if(Cache::get($lockKey) !== null) { return; } else { - Cache::put($lockKey, 1, 3600); + Cache::put($lockKey, 1, 43200); usleep(5000); } } dispatch(new DeleteWorker($headers, $payload))->onQueue('delete'); + } else if( isset($obj['type']) && in_array($obj['type'], ['Follow', 'Accept'])) { + dispatch(new InboxValidator($username, $headers, $payload))->onQueue('follow'); } else { $lockKey = 'pf:ap:user-inbox:activity:' . hash('sha256', $obj['id']); if(Cache::get($lockKey) !== null) { return; } - Cache::put($lockKey, 1, 3600); + Cache::put($lockKey, 1, 43200); usleep(5000); dispatch(new InboxValidator($username, $headers, $payload))->onQueue('high'); } @@ -219,10 +221,12 @@ class FederationController extends Controller return; } } - Cache::put($lockKey, 1, 3600); + Cache::put($lockKey, 1, 43200); dispatch(new DeleteWorker($headers, $payload))->onQueue('delete'); + } else if( isset($obj['type']) && in_array($obj['type'], ['Follow', 'Accept'])) { + dispatch(new InboxWorker($headers, $payload))->onQueue('follow'); } else { - dispatch(new InboxWorker($headers, $payload))->onQueue('high'); + dispatch(new InboxWorker($headers, $payload))->onQueue('shared'); } return; } diff --git a/config/horizon.php b/config/horizon.php index 19872ad3b..1f797fd1b 100644 --- a/config/horizon.php +++ b/config/horizon.php @@ -80,6 +80,8 @@ return [ 'waits' => [ 'redis:feed' => 30, + 'redis:follow' => 30, + 'redis:shared' => 30, 'redis:default' => 30, 'redis:low' => 30, 'redis:high' => 30, @@ -169,7 +171,7 @@ return [ 'production' => [ 'supervisor-1' => [ 'connection' => 'redis', - 'queue' => ['high', 'default', 'feed', 'low', 'story', 'delete', 'mmo'], + 'queue' => ['high', 'default', 'follow', 'shared', 'feed', 'low', 'story', 'delete', 'mmo'], 'balance' => env('HORIZON_BALANCE_STRATEGY', 'auto'), 'minProcesses' => env('HORIZON_MIN_PROCESSES', 1), 'maxProcesses' => env('HORIZON_MAX_PROCESSES', 20), @@ -183,7 +185,7 @@ return [ 'local' => [ 'supervisor-1' => [ 'connection' => 'redis', - 'queue' => ['high', 'default', 'feed', 'low', 'story', 'delete', 'mmo'], + 'queue' => ['high', 'default', 'follow', 'shared', 'feed', 'low', 'story', 'delete', 'mmo'], 'balance' => 'auto', 'minProcesses' => 1, 'maxProcesses' => 20, From e26d2ee0849262b1ffe526fc52650500ffcc5d09 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 12 Dec 2022 20:22:41 -0700 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d45df9e08..b6d24f61a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ - Update sidebar menu, when clicking on the active feed/timeline buttons force a reload and scroll to top of feed ([78a5575d](https://github.com/pixelfed/pixelfed/commit/78a5575d)) - Update InboxPipeline, increase timeout from 60s to 300s ([d1b888b5](https://github.com/pixelfed/pixelfed/commit/d1b888b5)) - Update backup config, fixes #3793, #3920, #3931 ([b0c4cc30](https://github.com/pixelfed/pixelfed/commit/b0c4cc30)) +- Update FederationController, add two new queues (follow, shared) to prioritize follow request handling ([8ba33864](https://github.com/pixelfed/pixelfed/commit/8ba33864)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4)