Cloud Functions로 무엇을 할 수 있나요?
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Cloud Functions를 사용하여 개발자가 Firebase 및 Google Cloud 이벤트에 액세스하고 확장 가능한 컴퓨팅 성능을 동원하여 이벤트에 대한 응답으로 코드를 실행할 수 있습니다. Firebase 앱은
고유한 요구사항을 해결하기 위해 제각각의 방식으로 Cloud Functions를 사용할 수 있지만,
일반적인 사용 사례는 다음과 같이 분류할 수 있습니다.
관심 있는 카테고리의 사용 사례와 예시를 각각 검토한 후 시작하기 가이드를 진행하거나 인증 이벤트, 애널리틱스 이벤트 등에 대한 구체적 안내 가이드를 진행합니다.
관심을 가질 만한 상황이 발생할 때 사용자에게 알림
개발자는 Cloud Functions로 사용자 참여도를 유지하고 앱 관련 최신 정보를 제공할 수 있습니다. 예를 들어 사용자들이 서로의 앱 활동을 팔로우할 수 있는 앱이 있다고 가정해 보겠습니다. 사용자가 자신을 다른 사용자의 팔로어로 추가할 때마다 Realtime Database에 쓰기가 수행됩니다. 그러면 이 쓰기 이벤트는 Firebase Cloud Messaging(FCM) 알림을 만드는 함수를 트리거하여 새 팔로어가 늘어났음을 해당 사용자에게 알릴 수 있습니다.

- 팔로어가 저장되는 Realtime Database 경로에 쓰기가 발생하면 함수가 트리거됩니다.
- 함수에서 FCM을 통해 전송할 메시지를 작성합니다.
- FCM에서 사용자의 기기로 알림 메시지를 전송합니다.
작동하는 코드를 검토하려면 GitHub의 샘플 코드를 참조하세요.
관심을 가질 만한 알림의 기타 사용 사례
- 뉴스레터를 구독하거나 구독 취소한 사용자에게 확인 이메일을 보냅니다.
- 가입을 완료한 사용자에게 환영 이메일을
보냅니다.
- 새 계정을 만든 사용자에게 SMS 확인을 보냅니다.
데이터베이스 정리 및 유지보수 수행
Cloud Functions 데이터베이스 이벤트 처리를 통해 사용자 동작에 따라 Realtime Database 또는 Cloud Firestore를 수정하여 시스템을 원하는 상태로 유지할 수 있습니다. 예를 들어 쓰기 이벤트를 모니터링하고 사용자 메시지의 특정 문자열 형식을 변경할 수 있습니다(예: 모두 대문자로 변경).
작동 방식은 다음과 같습니다.

- 함수의 데이터베이스 이벤트 핸들러는 특정 경로의 쓰기 이벤트를 수신 대기하면서 모든 채팅 메시지의 텍스트를 포함하는 이벤트 데이터를 검색합니다.
- 이 함수는 텍스트를 처리하여 문자열을 대문자로 변경합니다.
- 함수에서 업데이트된 텍스트를 데이터베이스에 다시 씁니다.
작동하는 코드를 검토하려면 GitHub의 샘플 코드를 참조하세요.
데이터베이스 정리 및 유지보수의 기타 사용 사례
- 삭제된 사용자의 콘텐츠를 Realtime Database에서 삭제합니다.
- Firebase 데이터베이스의 하위 노드 수를 제한합니다.
- Realtime Database 목록의 요소 개수를 추적합니다.
- Realtime Database에서 Google Cloud BigQuery로 데이터를 복사합니다.
- 텍스트를 그림 이모티콘으로 변환합니다.
- 데이터베이스 레코드의 계산된 메타데이터를 관리합니다.
앱이 아닌 클라우드에서 집약적인 작업 실행
Cloud Functions를 활용하면 Google Cloud 리소스 집약적인 작업(CPU 또는 네트워킹 과다 사용)을 사용자 기기에서 실행하는 대신 오프로드하여 앱의 응답성을 개선할 수 있습니다. 예를 들어 Cloud Storage에 대한 이미지 업로드를 리슨하는 함수를 작성하고 함수를 실행하는 인스턴스로 이미지를 다운로드하여 수정한 후 Cloud Storage에 다시 업로드할 수 있습니다. sharp 또는 Pillow와 같은 도구를 사용하여 이미지 크기 조절, 자르기 또는 변환을 수행할 수 있습니다.

- Cloud Storage에 이미지 파일이 업로드되면 함수가 트리거됩니다.
- 함수에서 이미지를 다운로드하고 썸네일을 만듭니다.
- 클라이언트 앱에서 썸네일을 찾아서 사용할 수 있도록 함수에서 해당 위치를 데이터베이스에 기록합니다.
- 함수에서 미리보기 이미지를 Cloud Storage에 새 위치로 다시 업로드합니다.
- 앱에서 미리보기 이미지 링크를 다운로드합니다.
이미지 처리 예시를 살펴보려면 Cloud Storage 이벤트 처리 가이드를 참조하세요.
Firebase 클라우드 일괄 작업의 기타 예
- 사용되지 않는 Firebase 계정(Node.js | Python)을 주기적으로 삭제합니다.
- 업로드된 이미지(Node.js | Python)를 자동으로 백업합니다.
- 사용자에게 대량으로 이메일을 보냅니다.
- 주기적으로 데이터를 집계하고 요약합니다.
- 대기 중인 작업의 큐를 처리합니다.
서드 파티 서비스 및 API와 통합
Cloud Functions를 사용하면 웹 API를 호출하고 외부에 노출하여 앱과 다른 서비스의 연동을 강화할 수 있습니다. 예를 들어 개발 공동작업에 사용되는 앱에서 작업 그룹 채팅방에 GitHub 커밋을 게시할 수 있습니다.

- 사용자가 GitHub 저장소로 커밋을 푸시합니다.
- GitHub webhook API를 통해 HTTPS 함수가 트리거됩니다.
- 함수에서 팀의 Slack 채널에 커밋 알림을 보냅니다.
서드 파티 서비스 및 API와 통합하는 다른 방법
- Google Cloud Vision API를 사용하여 업로드된 이미지를 분석하고 태그를 지정합니다.
- Google 번역을 사용하여 메시지를 번역합니다.
- 커스텀 인증을 사용하여 사용자를 로그인합니다.
- Realtime Database 쓰기에 대한 웹훅으로 요청을 보냅니다.
- Realtime Database 요소에 대한 전체 텍스트 검색을 사용 설정합니다.
- 사용자의 결제를 처리합니다.
- 전화 통화 및 SMS 메시지의 자동 응답을 만듭니다.
- Google 어시스턴트를 사용하여 챗봇을 만듭니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-17(UTC)
[null,null,["최종 업데이트: 2025-08-17(UTC)"],[],[],null,["\u003cbr /\u003e\n\nCloud Functions gives developers access to Firebase and Google Cloud\nevents, along with\nscalable computing power to run code in response to those events. While it's\nexpected that Firebase apps will use Cloud Functions in unique ways to meet\ntheir unique requirements, typical use cases might fall into these areas:\n\n- [Notify users when something interesting happens](#notify_users_when_something_interesting_happens).\n- [Perform database sanitization and maintenance](#perform_database_sanitization_and_maintenance).\n- [Execute intensive tasks in the cloud instead of in your app](#execute_intensive_tasks_in_the_cloud_instead_of_in_your_app).\n- [Integrate with third-party services and APIs](#integrate_with_third-party_services_and_apis).\n\nReview the use cases and examples for each category that interests\nyou, and then proceed to our [Get Started](/docs/functions/get-started) tutorial\nor to specific how-to guides\nfor [authentication events](/docs/functions/auth-events),\n[analytics events](/docs/functions/analytics-events), and more.\n\nNotify users when something interesting happens\n\nDevelopers can use Cloud Functions to keep users engaged and up to date\nwith relevant information about an app. Consider, for example, an app that\nallows users to follow one another's activities in the app. Each time a user\nadds themselves as a follower of another user, a write occurs in the\nRealtime Database. Then this write event could trigger a function\nto create Firebase Cloud Messaging (FCM) notifications to let the appropriate\nusers know that they have gained new followers.\n\n1. The function triggers on writes to the Realtime Database path where followers are stored.\n2. The function composes a message to send via .\n3. sends the notification message to the user's device.\n\nTo review working code, see the sample code in GitHub:\n\n- Node.js: [fcm-notifications](https://github.com/firebase/functions-samples/tree/main/Node/fcm-notifications)\n- Python: [fcm-notifications](https://github.com/firebase/functions-samples/tree/main/Python/fcm-notifications)\n\nOther interesting notification use cases\n\n- Send confirmation emails to users subscribing to a newsletter.\n- Send a welcome email when a user completes signup.\n- Send an SMS confirmation when a user creates a new account.\n\nPerform database sanitization and maintenance\n\nWith Cloud Functions database event handling, you can modify Realtime Database or\nCloud Firestore in response to user behavior, keeping the system in your desired\nstate. For example, you could monitor write events and change the format\n(for example, change to all uppercase) of certain strings in users' messages.\nHere's how that could work:\n\n1. The function's database event handler listens for write events on a specific path, and retrieves event data containing the text of a messages.\n2. The function processes the text to change strings to uppercase.\n3. The function writes the updated text back to the database.\n\nTo review working code, see the sample code in GitHub:\n\n- Node.js: [uppercase-rtdb](https://github.com/firebase/functions-samples/tree/main/Node/quickstarts/uppercase-rtdb)\n- Python: [uppercase-rtdb](https://github.com/firebase/functions-samples/tree/main/Python/quickstarts/uppercase-rtdb)\n\nOther database sanitization and maintenance use cases\n\n- Purge a deleted user's content from Realtime Database.\n- Limit the number of child nodes in a Firebase database.\n- Track the number of elements in a Realtime Database list.\n- Copy data from Realtime Database to Google Cloud BigQuery.\n- Convert text to emoji.\n- Manage computed metadata for database records.\n\nExecute intensive tasks in the cloud instead of in your app\n\nYou can take advantage of Cloud Functions to offload to the Google\ncloud resource-intensive work (heavy CPU or networking) instead of running it\non a user's device, improving the responsiveness of your app.\nFor instance, you could write a function\nto listen for image uploads to Cloud Storage, download the image to the instance\nrunning the function, modify it, and upload it back to Cloud Storage. Your\nmodifications could include resizing, cropping, or converting images with tools\nlike [sharp](https://www.npmjs.com/package/sharp) or\n[Pillow](https://pillow.readthedocs.io/en/stable/).\n\n1. A function triggers when an image file is uploaded to Cloud Storage.\n2. The function downloads the image and creates a thumbnail version of it.\n3. The function writes that thumbnail location to the database, so a client app can find and use it.\n4. The function uploads the thumbnail back to Cloud Storage in a new location.\n5. The app downloads the thumbnail link.\n\nFor a walkthrough of an image processing example, see the guide to\n[handling Cloud Storage events](https://firebase.google.com/docs/functions/gcp-storage-events?gen=2nd).\n\nOther examples of batch jobs in the Firebase cloud\n\n- Periodically delete unused Firebase accounts [Node.js](https://github.com/firebase/functions-samples/tree/main/Node/delete-unused-accounts-cron) \\| [Python](https://github.com/firebase/functions-samples/tree/main/Python/delete-unused-accounts-cron).\n- Automatically back up uploaded images [Node.js](https://github.com/firebase/functions-samples/tree/main/Node/taskqueues-backup-images) \\| [Python](https://github.com/firebase/functions-samples/tree/main/Python/taskqueues-backup-images).\n- Send bulk email to users.\n- Aggregate and summarize data periodically.\n- Process a queue of pending work.\n\nIntegrate with third-party services and APIs\n\nCloud Functions can help your app work better with other services by\ncalling and exposing web APIs. For instance, an app used for collaboration on\ndevelopment could post GitHub commits to a workgroup chat room.\n\n1. A user pushes commits to a GitHub repo.\n2. An HTTPS function triggers via the [GitHub webhook API](https://developer.github.com/webhooks/).\n3. The function sends a notification of the commit to a team Slack channel.\n\nOther ways to integrate with third-party services and APIs\n\n- Use Google [Cloud Vision API](https://cloud.google.com/vision/) to analyze and tag uploaded images.\n- Translate messages using Google Translate.\n- Use [custom auth](https://firebase.google.com/docs/auth/where-to-start#custom-auth) to sign in users.\n- Send a request to a webhook on Realtime Database writes.\n- Enable full-text search on Realtime Database elements.\n- Process payments from users.\n- Create auto-responses to phone calls and SMS messages.\n- Create a chatbot using Google Assistant."]]