Skip to content

[#336] Firebase CPU quota 부족 문제를 해결한다#340

Merged
opficdev merged 4 commits intodevelopfrom
fix/#336-Firestore-cpu-quota
Mar 31, 2026
Merged

[#336] Firebase CPU quota 부족 문제를 해결한다#340
opficdev merged 4 commits intodevelopfrom
fix/#336-Firestore-cpu-quota

Conversation

@opficdev
Copy link
Copy Markdown
Owner

@opficdev opficdev self-assigned this Mar 31, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이번 풀 리퀘스트는 firebase-functions 라이브러리를 7.2.2 버전으로 업데이트하고, 전반적인 클라우드 함수의 maxInstances 설정을 하향 조정하여 리소스 사용을 최적화합니다. 리뷰 결과, onCall 함수의 인스턴스 제한(2)은 트래픽 증가 시 429 Too Many Requests 에러를 유발할 수 있어 상향 조정이 권장되었습니다. 또한, onTaskDispatchedonSchedule 함수의 인스턴스를 1로 제한할 경우 처리 속도 저하나 작업 중첩에 따른 실행 실패 가능성이 있어 이에 대한 검토가 필요합니다.

export const requestAppleCustomToken = onCall({
cors: true,
maxInstances: 10,
maxInstances: 2,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

인증과 같이 사용자 경험에 직결되는 onCall 함수의 maxInstances를 2로 설정하면, 동시 사용자가 조금만 늘어나도 429 Too Many Requests 에러가 발생할 위험이 큽니다. CPU 쿼터 절약도 중요하지만, 서비스 가용성을 위해 이 값을 조금 더 여유 있게 설정(예: 5~10)하는 것을 권장합니다. 이 의견은 다른 파일의 onCall 함수들에도 공통적으로 적용됩니다.

Suggested change
maxInstances: 2,
maxInstances: 5,


// Cloud Tasks에 의해 트리거되는 함수
export const sendPushNotification = onTaskDispatched({
maxInstances: 1,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

onTaskDispatched 함수의 maxInstances를 1로 제한하면, rateLimits에 설정된 초당 200건의 처리 속도를 달성하기 어렵고 대량의 알림 발송 시 지연이 발생할 수 있습니다. 쿼터 제한을 위한 의도적인 설정이라 하더라도, 알림 발송의 실시간성을 고려하여 인스턴스 수를 조정하거나 지연 허용 여부를 확인해 보시기 바랍니다.

};

export const scheduleTodoReminder = onSchedule({
maxInstances: 1,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

onSchedule 함수의 maxInstances를 1로 설정할 경우, 이전 실행이 5분 내에 끝나지 않으면 다음 스케줄 실행이 실패할 수 있습니다. 현재 모든 사용자를 조회하는 로직의 특성상 사용자 증가 시 실행 시간이 길어질 수 있으므로, 실행 시간을 모니터링하거나 인스턴스 제한을 소폭 늘리는 것을 검토해 주세요.

@opficdev opficdev merged commit a566f66 into develop Mar 31, 2026
1 check passed
@opficdev opficdev deleted the fix/#336-Firestore-cpu-quota branch March 31, 2026 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Firebase CPU quota 부족 문제를 해결한다

1 participant