Reduce cost using Google Cloud Function

May 16, 2025

💡 How to reduced backend costs by 98% using Express and Google Cloud Functions

Recently, I set out to reduce the cost of running a lightweight backend app originally deployed on a Google Compute Engine (E2.small), which was costing around $13/month.

The backend was built with Nest.js, but since the workload was minimal, I explored migrating it to Express.js on Google Cloud Functions.

After switching, the estimated cost—according to the [Google Cloud Pricing Calculator]—dropped by *** 98% ***(we hit the endpoint once per minute and each request takes less than 1 second).

I couldn’t find useful resources or sample code showing how to integrate Express with Cloud Functions. So, I’ve decided to share the architecture and setup I used to help others looking to do the same.

If you’re running a simple backend and want to optimize costs, this approach might be worth considering--plus, a major bonus is you no longer have to worry about backend crashes.. đŸ’Ș

code snippet