mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-22 21:45:13 +01:00
perf: Tune AP job queue timings (#7635)
* perf: Tune AP job queue timings * CHANGELOG * chore: add reference Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
parent
0e69091455
commit
bb2db1cf76
3 changed files with 21 additions and 7 deletions
|
@ -12,6 +12,7 @@
|
||||||
### Improvements
|
### Improvements
|
||||||
- 依存関係の更新
|
- 依存関係の更新
|
||||||
- localStorageのaccountsはindexedDBで保持するように
|
- localStorageのaccountsはindexedDBで保持するように
|
||||||
|
- ActivityPub: ジョブキューの試行タイミングを調整 (#7635)
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
- チャンネルを作成しているとアカウントを削除できないのを修正
|
- チャンネルを作成しているとアカウントを削除できないのを修正
|
||||||
|
|
|
@ -73,8 +73,7 @@ export function deliver(user: ThinUser, content: unknown, to: string | null) {
|
||||||
attempts: config.deliverJobMaxAttempts || 12,
|
attempts: config.deliverJobMaxAttempts || 12,
|
||||||
timeout: 1 * 60 * 1000, // 1min
|
timeout: 1 * 60 * 1000, // 1min
|
||||||
backoff: {
|
backoff: {
|
||||||
type: 'exponential',
|
type: 'apBackoff'
|
||||||
delay: 60 * 1000
|
|
||||||
},
|
},
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true
|
removeOnFail: true
|
||||||
|
@ -91,8 +90,7 @@ export function inbox(activity: IActivity, signature: httpSignature.IParsedSigna
|
||||||
attempts: config.inboxJobMaxAttempts || 8,
|
attempts: config.inboxJobMaxAttempts || 8,
|
||||||
timeout: 5 * 60 * 1000, // 5min
|
timeout: 5 * 60 * 1000, // 5min
|
||||||
backoff: {
|
backoff: {
|
||||||
type: 'exponential',
|
type: 'apBackoff'
|
||||||
delay: 60 * 1000
|
|
||||||
},
|
},
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true
|
removeOnFail: true
|
||||||
|
|
|
@ -11,8 +11,23 @@ export function initialize<T>(name: string, limitPerSec = -1) {
|
||||||
},
|
},
|
||||||
prefix: config.redis.prefix ? `${config.redis.prefix}:queue` : 'queue',
|
prefix: config.redis.prefix ? `${config.redis.prefix}:queue` : 'queue',
|
||||||
limiter: limitPerSec > 0 ? {
|
limiter: limitPerSec > 0 ? {
|
||||||
max: limitPerSec * 5,
|
max: limitPerSec,
|
||||||
duration: 5000
|
duration: 1000
|
||||||
} : undefined
|
} : undefined,
|
||||||
|
settings: {
|
||||||
|
backoffStrategies: {
|
||||||
|
apBackoff
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ref. https://github.com/misskey-dev/misskey/pull/7635#issue-971097019
|
||||||
|
function apBackoff(attemptsMade: number, err: Error) {
|
||||||
|
const baseDelay = 60 * 1000; // 1min
|
||||||
|
const maxBackoff = 8 * 60 * 60 * 1000; // 8hours
|
||||||
|
let backoff = (Math.pow(2, attemptsMade) - 1) * baseDelay;
|
||||||
|
backoff = Math.min(backoff, maxBackoff);
|
||||||
|
backoff += Math.round(backoff * Math.random() * 0.2);
|
||||||
|
return backoff;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue