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