Cloud functions — High-level overview

Yonatan Merkebu
2 min readApr 15, 2022

Cloud functions are known as serverless computing. But serverless is not actually serverless. A cloud function actually is a Node js server that is already pre-configured and sitting there for you on demand.

The reason it is called serverless is that you don't have to do the normal stuff you would have to deal with actual servers such as load balancing, networking, and so on.

Types of cloud functions

There are two types of cloud functions in firebase. Which are HTTP and Background.

HTTP functions allow you to build restful endpoints that give you an actual URL to call from your client-side codes.

Everything else is basically a Background function that gets triggered by some other event in your firebase app.

There is an event for almost everything. If a new user signs up, if a new file is uploaded, if something changes in the database, the list goes on.

This is what makes cloud functions and serverless computing in general super powerful. Because you can build a reactive style infrastructure that will allow you to do things in a lot less code and in a much more reliable and cost-effective way.

The other most popular way to build a backend is to write your code and deploy it to the cloud as a docker container. If you want to scale up, you just deploy more containers.

Cloud functions on the other hand are pay-as-you-go and they scale with your actual usage in a linear way.

Pricing

Firebase cloud functions will charge you based on these 3 main factors

  • Invocations — the number of times a function is called
  • GB-Seconds — memory GB usage
  • CPU-Seconds — CPU usage

You can read more about google cloud functions pricing at this link.

Cloud functions pricing is much more cost-effective in the early stages of development compared to the docker container approach. That is also on development time and cloud computing cost.

That's it for Cloud functions high-level overview. Follow me for more advanced topics on cloud functions.

--

--