Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Ada dua versi Cloud Functions for Firebase:
Cloud Functions (generasi ke-2), yang men-deploy fungsi sebagai layanan di Cloud Run, sehingga Anda dapat memicunya menggunakan Eventarc dan Pub/Sub.
Cloud Functions (generasi ke-1), versi asli fungsi dengan pemicu peristiwa dan kemampuan konfigurasi terbatas.
Sebaiknya pilih Cloud Functions (generasi ke-2) untuk mendapatkan fungsi-fungsi barunya, jika memungkinkan. Namun, kami berencana untuk terus mendukung Cloud Functions (generasi ke-1).
Halaman ini menjelaskan fitur yang diperkenalkan di Cloud Functions dan memberikan perbandingan antara kedua versi produk tersebut.
Cloud Functions (generasi ke-2)
Cloud Functions adalah penawaran Functions as a Service generasi berikutnya dari Firebase. Dibangun di Cloud Run dan Eventarc, Cloud Functions (generasi ke-2) menghadirkan
infrastruktur yang ditingkatkan
dan cakupan peristiwa yang lebih luas ke Cloud Functions, termasuk:
Dibangun di Cloud Run: Fungsi dibangun dengan Cloud Build dan di-deploy sebagai layanan Cloud Run menggunakan lingkungan eksekusi Cloud Run default.
Hal ini memberi Anda kemampuan untuk menyesuaikan fungsi seperti halnya layanan Cloud Run. Lihat dokumentasi Cloud Run untuk mempelajari berbagai opsi untuk mengonfigurasi layanan Anda, seperti batas memori, variabel lingkungan, dan sebagainya.
Waktu pemrosesan permintaan yang lebih lama: Menjalankan beban kerja permintaan yang lebih lama, misalnya memproses aliran data yang besar dari Cloud Storage atau BigQuery.
Ukuran instance yang lebih besar: Menjalankan beban kerja dalam memori, komputasi yang intensif, dan
paralel yang lebih besar.
Pengelolaan permintaan serentak yang lebih baik: Menangani beberapa permintaan serentak dengan satu instance fungsi untuk meminimalkan cold start dan menurunkan latensi.
Pengelolaan traffic: Memisahkan traffic di antara revisi fungsi yang berbeda atau melakukan roll back fungsi ke versi sebelumnya.
Integrasi Eventarc: Dukungan native untuk pemicu
Eventarc, yang menghadirkan lebih dari 90 sumber peristiwa yang didukung oleh Eventarc ke
Cloud Functions.
Dukungan CloudEvents yang lebih luas: Dukungan untuk CloudEvents standar industri di semua runtime bahasa, sehingga memberikan pengalaman developer yang konsisten.
Karena Cloud Functions men-deploy fungsi sebagai layanan di Cloud Run, Cloud Functions berbagi kuota dan batas resource dengan Cloud Run. Lihat Kuota.
Tabel perbandingan
Fitur
Cloud Functions (generasi ke-1)
Cloud Functions
Registry image
Container Registry atau Artifact Registry
Artifact Registry saja
Waktu tunggu permintaan
Hingga 9 menit
Hingga 60 menit untuk fungsi yang dipicu HTTP
Hingga 9 menit untuk fungsi yang dipicu peristiwa
Akun layanan*
Akun layanan Google App Engine (PROJECT_ID@appspot.gserviceaccount.com)
Akun layanan komputasi default Google Cloud (PROJECT_NUMBER-compute@developer.gserviceaccount.com)
Ukuran instance
RAM hingga 8 GB dengan 2 vCPU
RAM hingga 16 GiB dengan 4 vCPU
Serentak
1 permintaan serentak per instance fungsi
Hingga 1.000 permintaan serentak per instance fungsi
* Akun ini adalah akun layanan default yang digunakan untuk mengakses Firebase atau Cloud API
dari fungsi yang sedang berjalan. Akun ini digunakan oleh Firebase Admin SDK saat Anda
melakukan inisialisasi tanpa argumen.
Jika diminta, pilih akun penagihan yang terkait dengan
projek Google Cloud Anda.
Di panel Filters, di bagian Labels, tambahkan filter label dengan kunci goog-managed-by dan nilai cloudfunctions.
Batasan
Cloud Functions for Firebase (generasi ke-2) tidak memberikan dukungan untuk peristiwa Analytics.
Meskipun mendukung peristiwa pemblokiran
autentikasi, Cloud Functions for Firebase (generasi ke-2) tidak mendukung kumpulan peristiwa Authentication dasar yang sama seperti
generasi ke-1.
Namun, karena fungsi generasi ke-1 dan generasi ke-2 dapat berdampingan dalam file sumber yang sama, Anda masih dapat mengembangkan dan men-deploy pemicu Analytics dan Authentication dasar di generasi ke-1 bersama dengan fungsi generasi ke-2.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-05 UTC."],[],[],null,["\u003cbr /\u003e\n\nThere are two versions of Cloud Functions for Firebase:\n\n- **Cloud Functions (2nd gen)** , which deploys your functions as services on Cloud Run, allowing you to trigger them using Eventarc and Pub/Sub.\n- **Cloud Functions (1st gen)**, the original version of functions with limited event triggers and configurability.\n\nWe recommend that you choose Cloud Functions (2nd gen) for new functions\nwherever possible. However, we plan to continue supporting Cloud Functions\n(1st gen).\n\nThis page describes features introduced in Cloud Functions and\nprovides a comparison between the two product versions.\n\nCloud Functions (2nd gen)\n\nCloud Functions is Firebase's next-generation\nFunctions-as-a-Service offering. Built on Cloud Run and\nEventarc, Cloud Functions (2nd gen) brings enhanced\ninfrastructure and broader event coverage to Cloud Functions, including:\n\n- **Built on Cloud Run** : Functions are built with Cloud Build and deployed as Cloud Run services using the default [Cloud Run execution environment](//cloud.google.com/run/docs/about-execution-environments). This gives you the ability to customize your function as you would a Cloud Run service. Refer to Cloud Run documentation to explore options for configuring your service, such as [memory\n limits](//cloud.google.com/run/docs/configuring/services/memory-limits), [environment variables](//cloud.google.com/run/docs/configuring/services/environment-variables), and so forth.\n- **Longer request processing times** : Run longer-request workloads such as processing large streams of data from Cloud Storage or BigQuery.\n- **Larger instance sizes**: Run larger in-memory, compute-intensive, and parallel workloads.\n- **Improved concurrency**: Handle multiple concurrent requests with a single function instance to minimize cold starts and improve latency.\n- **Traffic management**: Split traffic between different function revisions or roll a function back to a prior version.\n- **Eventarc integration** : Native support for Eventarc triggers, bringing all 90+ event sources supported by Eventarc to Cloud Functions.\n- **Broader CloudEvents support** : Support for industry-standard [CloudEvents](https://cloudevents.io/) in all language runtimes, providing a consistent developer experience.\n\nSee the [comparison table](#comparison-table) for details.\n\nBecause Cloud Functions deploys functions as services on Cloud Run,\nCloud Functions shares resource quotas and limits with\nCloud Run. See [Quotas](/docs/functions/quotas).\n\nComparison table\n\n| Feature | Cloud Functions (1st gen) | Cloud Functions |\n|-------------------|------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| Image registry | Container Registry or Artifact Registry | Artifact Registry only |\n| Request timeout | Up to 9 minutes | - Up to 60 minutes for HTTP-triggered functions - Up to 9 minutes for event-triggered functions |\n| Service account\\* | Google App Engine service account (\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e@appspot.gserviceaccount.com) | Google Cloud default compute service account (\u003cvar translate=\"no\"\u003ePROJECT_NUMBER\u003c/var\u003e-compute@developer.gserviceaccount.com) |\n| Instance size | Up to 8GB RAM with 2 vCPU | Up to 16GiB RAM with 4 vCPU |\n| Concurrency | 1 concurrent request per function instance | Up to 1000 concurrent requests per function instance |\n\n\\* This is the default service account used to access Firebase or Cloud APIs\nfrom a running function. It is used by the Firebase Admin SDK when you\n[initialize without arguments](/docs/admin/setup#initialize-sdk).\n\nPricing\n\nFor pricing information, see [Firebase pricing plans](https://firebase.google.com/pricing#cloud-functions).\n\nYou can view your costs associated with Cloud Functions as follows:\n\n1. Go to the [Cloud Billing Reports page](https://console.cloud.google.com/billing/reports) in the Google Cloud console.\n2. If prompted, select the billing account associated with your Google Cloud project.\n3. In the **Filters** panel, under **Labels** , [add a label filter](//cloud.google.com//billing/docs/how-to/reports#filters) with the key `goog-managed-by` and the value `cloudfunctions`.\n\n| **Note:** If you are using Cloud Functions for Firebase (1st gen) and are interested in Cloud Functions, see [Upgrade 1st gen Node.js functions to 2nd gen](/docs/functions/2nd-gen-upgrade).\n\nLimitations\n\nCloud Functions for Firebase (2nd gen) does not provide support for Analytics\nevents.\n\nThough Cloud Functions for Firebase (2nd gen) supports authentication blocking\nevents, it does not support the same set of basic Authentication events as\n1st gen.\n\nHowever, because 1st gen and 2nd gen\nfunctions can coexist side-by-side in the same source file, you can still\ndevelop and deploy Analytics and basic Authentication triggers in 1st gen\ntogether with 2nd gen functions."]]