Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export class MetricsCacheService implements OnModuleInit, OnModuleDestroy {
const tls = useTls
? {
rejectUnauthorized: process.env.REDIS_REJECT_UNAUTHORIZED !== "false",
checkServerIdentity:
process.env.REDIS_CHECK_SERVER_IDENTITY === "false"
? () => undefined
: undefined,
}
: undefined;

Expand Down
34 changes: 30 additions & 4 deletions backend/src/query-api/service-metrics/service-metrics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,19 @@ export class ServiceMetricsService {

const cacheKey =
this.rollupCacheAvailable() &&
window.isSlidingWindow &&
this.buildRollupCacheKey(normalized, window);
if (cacheKey) {
const cached = await this.metricsCache.get(cacheKey);
if (cached) {
this.logger.debug(
`롤업 캐시 히트 service=${normalized.serviceName} window=${this.formatTimestamp(window.from)}~${this.formatTimestamp(window.to)}`,
);
return JSON.parse(cached) as ServiceMetricBucket[];
}
this.logger.debug(
`롤업 캐시 미스 service=${normalized.serviceName} window=${this.formatTimestamp(window.from)}~${this.formatTimestamp(window.to)}`,
);
}

const fromMs = Date.parse(window.from);
Expand Down Expand Up @@ -328,7 +335,11 @@ export class ServiceMetricsService {
if (!this.rollupEnabled) {
return {
rollupWindow: null,
rawWindow: { from: normalized.from, to: normalized.to },
rawWindow: {
from: normalized.from,
to: normalized.to,
isSlidingWindow: normalized.isSlidingWindow,
},
};
}

Expand All @@ -337,14 +348,22 @@ export class ServiceMetricsService {
if (!Number.isFinite(fromMs) || !Number.isFinite(toMs) || toMs <= fromMs) {
return {
rollupWindow: null,
rawWindow: { from: normalized.from, to: normalized.to },
rawWindow: {
from: normalized.from,
to: normalized.to,
isSlidingWindow: normalized.isSlidingWindow,
},
};
}

if (toMs - fromMs <= this.rollupThresholdMs) {
return {
rollupWindow: null,
rawWindow: { from: normalized.from, to: normalized.to },
rawWindow: {
from: normalized.from,
to: normalized.to,
isSlidingWindow: normalized.isSlidingWindow,
},
};
}

Expand All @@ -353,18 +372,24 @@ export class ServiceMetricsService {
if (splitPoint <= fromMs) {
return {
rollupWindow: null,
rawWindow: { from: normalized.from, to: normalized.to },
rawWindow: {
from: normalized.from,
to: normalized.to,
isSlidingWindow: normalized.isSlidingWindow,
},
};
}

const rollupWindow: MetricsWindow = {
from: normalized.from,
to: new Date(splitPoint).toISOString(),
isSlidingWindow: normalized.isSlidingWindow,
};

const rawWindow: MetricsWindow = {
from: rollupWindow.to,
to: normalized.to,
isSlidingWindow: normalized.isSlidingWindow,
};
return {
rollupWindow,
Expand Down Expand Up @@ -470,6 +495,7 @@ export class ServiceMetricsService {
interface MetricsWindow {
from: string;
to: string;
isSlidingWindow: boolean;
}

interface MetricsFetchPlan {
Expand Down
3 changes: 2 additions & 1 deletion backend/src/stream-processor/common/bulk-indexer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class BulkIndexerService implements OnModuleDestroy {
private readonly maxBatchSize: number;
private readonly maxBatchBytes: number;
private readonly flushIntervalMs: number;
// 병렬 플러시
private readonly maxParallelFlushes: number;

private buffer: BufferedItem[] = [];
Expand All @@ -48,7 +49,7 @@ export class BulkIndexerService implements OnModuleDestroy {
);
this.maxParallelFlushes = Math.max(
1,
Number.parseInt(process.env.BULK_MAX_PARALLEL_FLUSHES ?? "2", 10),
Number.parseInt(process.env.BULK_MAX_PARALLEL_FLUSHES ?? "3", 10),
);
}

Expand Down