perf: Remove "process" queue stat counter for performance (MisskeyIO#325)
This commit is contained in:
parent
397e056b1e
commit
9449218049
@ -9,7 +9,6 @@ import { QueueProcessorService } from '@/queue/QueueProcessorService.js';
|
||||
import { NestLogger } from '@/NestLogger.js';
|
||||
import { QueueProcessorModule } from '@/queue/QueueProcessorModule.js';
|
||||
import { QueueStatsService } from '@/daemons/QueueStatsService.js';
|
||||
import { ServerStatsService } from '@/daemons/ServerStatsService.js';
|
||||
import { ServerService } from '@/server/ServerService.js';
|
||||
import { MainModule } from '@/MainModule.js';
|
||||
|
||||
@ -24,8 +23,7 @@ export async function server() {
|
||||
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
app.get(ChartManagementService).start();
|
||||
// app.get(QueueStatsService).start();
|
||||
// app.get(ServerStatsService).start();
|
||||
app.get(QueueStatsService).start();
|
||||
}
|
||||
|
||||
return app;
|
||||
|
@ -34,24 +34,8 @@ export class QueueStatsService implements OnApplicationShutdown {
|
||||
*/
|
||||
@bindThis
|
||||
public start(): void {
|
||||
const log = [] as any[];
|
||||
|
||||
ev.on('requestQueueStatsLog', x => {
|
||||
ev.emit(`queueStatsLog:${x.id}`, log.slice(0, x.length ?? 50));
|
||||
});
|
||||
|
||||
let activeDeliverJobs = 0;
|
||||
let activeInboxJobs = 0;
|
||||
|
||||
const deliverQueueEvents = new Bull.QueueEvents(QUEUE.DELIVER, baseQueueOptions(this.config.redisForDeliverQueue, this.config.bullmqQueueOptions, QUEUE.DELIVER));
|
||||
const inboxQueueEvents = new Bull.QueueEvents(QUEUE.INBOX, baseQueueOptions(this.config.redisForInboxQueue, this.config.bullmqQueueOptions, QUEUE.INBOX));
|
||||
|
||||
deliverQueueEvents.on('active', () => {
|
||||
activeDeliverJobs++;
|
||||
});
|
||||
|
||||
inboxQueueEvents.on('active', () => {
|
||||
activeInboxJobs++;
|
||||
ev.emit(`queueStatsLog:${x.id}`, []);
|
||||
});
|
||||
|
||||
const tick = async () => {
|
||||
@ -60,13 +44,13 @@ export class QueueStatsService implements OnApplicationShutdown {
|
||||
|
||||
const stats = {
|
||||
deliver: {
|
||||
activeSincePrevTick: activeDeliverJobs,
|
||||
activeSincePrevTick: 0, // it's removed for performance reason
|
||||
active: deliverJobCounts.active,
|
||||
waiting: deliverJobCounts.waiting,
|
||||
delayed: deliverJobCounts.delayed,
|
||||
},
|
||||
inbox: {
|
||||
activeSincePrevTick: activeInboxJobs,
|
||||
activeSincePrevTick: 0, // it's removed for performance reason
|
||||
active: inboxJobCounts.active,
|
||||
waiting: inboxJobCounts.waiting,
|
||||
delayed: inboxJobCounts.delayed,
|
||||
@ -74,12 +58,6 @@ export class QueueStatsService implements OnApplicationShutdown {
|
||||
};
|
||||
|
||||
ev.emit('queueStats', stats);
|
||||
|
||||
log.unshift(stats);
|
||||
if (log.length > 200) log.pop();
|
||||
|
||||
activeDeliverJobs = 0;
|
||||
activeInboxJobs = 0;
|
||||
};
|
||||
|
||||
tick();
|
||||
|
Loading…
Reference in New Issue
Block a user