What is the difference between Cloud Functions and Firebase Functions?

24,361

Solution 1

There is no product called Firebase Functions.

There are three separate things:

  1. Google Cloud Functions, which allow you to run snippets of code in Google's infrastructure in response to events.
  2. Cloud Functions for Firebase, which triggers Google Cloud Functions based on events in Firebase (such as database or file writes, user creation, etc)
  3. Firebase SDK for Cloud Functions, which includes a library (confusingly called firebase-functions) that you use in your Functions code to access Firebase data (such as the snapshot of the data that was written to the database)

So Firebase provides a (relatively thin) wrapper around Google Cloud Functions, to make the latter product easier to use and integrate it with Firebase. In that senses it is similar to how Firebase integrates Google Cloud Storage into "Cloud Storage for Firebase" (formerly known as Firebase Storage).

If you're using Google Cloud Platform without Firebase, then you should use plain Google Cloud Functions. If you're on Firebase or if you're a mobile developer interested in Cloud Functions, you should use Cloud Functions for Firebase.

Solution 2

There is an additional difference: Firebase Functions can only be implemented in JS or Node.JS, while Cloud Functions also allow the use of Python and Go.

There is also a small difference in terms of how they are priced, if you are on the Spark Plan. Check this out https://firebase.google.com/pricing vs. https://cloud.google.com/functions/pricing if you are on the Blaze plan, the pricing is the same.

I happen to use both for my Firebase project.

Solution 3

Google Cloud Platform, GCP, has an article addressing this question, Google Cloud Functions and Firebase.

Google Cloud Functions and Firebase

Google Cloud Functions is Google's serverless compute solution for creating event-driven applications. It is a joint product between the Google Cloud Platform team and the Firebase team.

For Google Cloud Platform developers, Cloud Functions serve as a connective layer allowing you to weave logic between Google Cloud Platform (GCP) services by listening for and responding to events.

For Firebase developers, Cloud Functions for Firebase provides a way to extend the behavior of Firebase and integrate Firebase features through the addition of server-side code.

Both solutions provide fast and reliable execution of functions in a fully managed environment where there's no need for you to worry about managing any servers or provisioning any infrastructure.

...

Cloud Functions for Firebase is optimized for Firebase developers:

  • Firebase SDK to configure your functions through code
  • Integrated with Firebase Console and Firebase CLI
  • The same triggers as Google Cloud Functions, plus Firebase Realtime Database, Firebase Authentication, and Firebase Analytics triggers

Solution 4

Official Google Video Describing the difference: GCP vs. Firebase - Functions & Firestore

  1. Firebase will offer you to wrap your functions into callable functions which can be invoked via firebase SDK
  2. language support, GCP also supports Go, Python and java
  3. GCP could be deployed both via console or CLI, but firebase functions only via CLI
Share:
24,361

Related videos on Youtube

Muhammad chhota
Author by

Muhammad chhota

Updated on May 10, 2021

Comments

  • Muhammad chhota
    Muhammad chhota about 3 years

    Cloud Functions and Firebase Functions (or "Cloud Functions for Firebase") both look the same. Please describe the use case of each.

    Both use HTTP functions.

    In the Cloud Functions:

    exports.helloHttp = function helloHttp (req, res) {
      res.send(`Hello ${req.body.name || 'World'}!`);
    };
    

    And in the Firebase Functions:

    exports.helloWorld = functions.https.onRequest((request, response) => {
      response.send("Hello from Firebase!");
    });
    

    What is difference between these?

    • AL.
      AL. about 7 years
      The term for Firebase is actually Cloud Functions for Firebase, which is pretty much just Cloud Functions integrated with Firebase Services.
    • Muhammad chhota
      Muhammad chhota about 7 years
      So there is no difference between both?
    • viggy28
      viggy28 over 5 years
      Would like to add a simple point not exactly answers your question. You can code in different languages (NodeJS, Python. Heard Go is coming) using Google Cloud Functions.
  • Ultrasaurus
    Ultrasaurus over 6 years
    FYI: Firebase tools allow developers to access all of Google Cloud events. The "firebase-functions" SDK and Firebase CLI work together to allow developers to manage a set of functions with simple deploy command -- easy getting started, while you still have full access to Google Cloud Platform when you need it.
  • mancini0
    mancini0 about 6 years
    Isn't pricing different, however? Using Google Cloud Platform functions outside of the Firebase context gives me 5 GB of outbound data each month for free. Calling GCP functions from inside the Firebase context prohibits access to non-google services at the free tier. Outside networking access is allowed at the $25 level, or at the Blaze level (pay as you go), but even at the Blaze level, you are charged 40 cents per million invocations, but through GCP, your first 2 million invocations are free, and then are .40 cents per million.
  • Frank van Puffelen
    Frank van Puffelen about 6 years
    They run on the exact same infrastructure, so there can't be any difference in how they execute. On the Blaze plan, there is the same free quota. From the pricing page: "On the Blaze plan, Cloud Functions provides a perpetual free tier. The first 2,000,000 invocations, 400,000 GB-sec, 200,000 CPU-sec, and 5 GB of Internet egress traffic is provided for free each month. You are only charged on usage past this free allotment."
  • JohnAndrews
    JohnAndrews over 5 years
    Cloud Functions for Firebase does not support the functions to be written in python, am I right? Based on the sentence "You'll need a Node.js environment to write functions (...)"
  • Frank van Puffelen
    Frank van Puffelen over 5 years