Cloud Functions를 사용하여 개발자가 Firebase 및 Google Cloud 이벤트에 액세스하고 확장 가능한 컴퓨팅 성능을 동원하여 이벤트에 대한 응답으로 코드를 실행할 수 있습니다. Firebase 앱은
고유한 요구사항을 해결하기 위해 제각각의 방식으로 Cloud Functions를 사용할 수 있지만,
일반적인 사용 사례는 다음과 같이 분류할 수 있습니다.
관심 있는 카테고리의 사용 사례와 예시를 각각 검토한 후 시작하기 가이드를 진행하거나 인증 이벤트, 애널리틱스 이벤트 등에 대한 구체적 안내 가이드를 진행합니다.
관심을 가질 만한 상황이 발생할 때 사용자에게 알림
개발자는 Cloud Functions로 사용자 참여도를 유지하고 앱 관련 최신 정보를 제공할 수 있습니다. 예를 들어 사용자들이 서로의 앱 활동을 팔로우할 수 있는 앱이 있다고 가정해 보겠습니다. 사용자가 자신을 다른 사용자의 팔로어로 추가할 때마다 Realtime Database에 쓰기가 수행됩니다. 그러면 이 쓰기 이벤트는 Firebase Cloud Messaging(FCM) 알림을 만드는 함수를 트리거하여 새 팔로어가 늘어났음을 해당 사용자에게 알릴 수 있습니다.
Cloud Functions 데이터베이스 이벤트 처리를 통해 사용자 동작에 따라 Realtime Database 또는 Cloud Firestore를 수정하여 시스템을 원하는 상태로 유지할 수 있습니다. 예를 들어 쓰기 이벤트를 모니터링하고 사용자 메시지의 특정 문자열 형식을 변경할 수 있습니다(예: 모두 대문자로 변경).
작동 방식은 다음과 같습니다.
함수의 데이터베이스 이벤트 핸들러는 특정 경로의 쓰기 이벤트를 수신 대기하면서 모든 채팅 메시지의 텍스트를 포함하는 이벤트 데이터를 검색합니다.
Realtime Database에서 Google Cloud BigQuery로 데이터를 복사합니다.
텍스트를 그림 이모티콘으로 변환합니다.
데이터베이스 레코드의 계산된 메타데이터를 관리합니다.
앱이 아닌 클라우드에서 집약적인 작업 실행
Cloud Functions를 활용하면 Google Cloud 리소스 집약적인 작업(CPU 또는 네트워킹 과다 사용)을 사용자 기기에서 실행하는 대신 오프로드하여 앱의 응답성을 개선할 수 있습니다. 예를 들어 Cloud Storage에 대한 이미지 업로드를 리슨하는 함수를 작성하고 함수를 실행하는 인스턴스로 이미지를 다운로드하여 수정한 후 Cloud Storage에 다시 업로드할 수 있습니다. sharp 또는 Pillow와 같은 도구를 사용하여 이미지 크기 조절, 자르기 또는 변환을 수행할 수 있습니다.
Cloud Storage에 이미지 파일이 업로드되면 함수가 트리거됩니다.
함수에서 이미지를 다운로드하고 썸네일을 만듭니다.
클라이언트 앱에서 썸네일을 찾아서 사용할 수 있도록 함수에서 해당 위치를 데이터베이스에 기록합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(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."]]