<img height="1" width="1" style="display:none;" alt="" src="https://px.ads.linkedin.com/collect/?pid=2634489&amp;fmt=gif">

Infrastructure, Application Development, API Management, Getting Started with Google Cloud, Cloud Operations

Creating an API using Cloud Functions (Node.js)

By David Ressler | January 26, 2022

I am currently evaluating different Google Cloud products in trying to set up an API for developers to use in a mobile app.

 

How should I evaluate thinking between:

  • A single Cloud Function using Express.js to create multiple routes in an API (accessed via API Gateway), vs.
  • A single Cloud Function per API endpoint (accessed via API Gateway)

 

Best answer by yuval

Hello @davidressler 

Cloud Functions are based on Cloud Run. I like Cloud Run because you can build and run your own containers instead of having to think about supported environments in Cloud Functions.

Read “Getting started with API Gateway and Cloud Run”[1].

Regarding single Cloud Run service for multiple methods vs multiple Cloud Run services - consider resources usage by different methods, if you have a method that uses more memory or it is CPU intensive you might want to separate it to a different Cloud Run service with larger container size. You might want different scaling for different methods. You can also run each Cloud Run service using a separate service account with different roles - one service needs only permission to write to a specific GCS bucket and another needs permission to read a secret from Google Secret Manager.

 

[1] https://cloud.google.com/api-gateway/docs/get-started-cloud-run

 


Recent Articles

Data Analytics

Generative AI: Are You Behind?!

Review the latest insights from the AI Readiness Report.
By Bruno Aziza
Industry Solutions

Make "Gen AI Work": Landscape, SLMs vs. LLMs, Cost & More...

Discover the 5 metrics you need to know in order to be an exceptional CEO and Operator.
By Bruno Aziza
Google Cloud Strategy

AI Cheat Sheet

AI is no more and no less the drive to create robots with human minds so they can do everything we do and more. Use this cheat sheet to help decode the space.
By Leah Zitter