node.js – Firebase Cloud Functions gen2 upgrade increased server costs
A few weeks ago I was forced to upgrade my Cloud Functions to gen2 and my node.js from version 16 to 22. After I made this update my firebase costs ballooned overnight by 4x. I have had to shut down my server until I can figure out what could have caused this, because this isn’t sustainable at this new frustrating cost.
The only change I had to make to my code was the way the request handler is written. Below I will give the before and after versions of how this code currently looks.
How is this change causing my server to cost 4x as much? How I can reduce the cost again?
Before:
const runtimeRetryOpts = {
failurePolicy: true,
};
exports.webhook = functions
.runWith(runtimeRetryOpts)
.https.onRequest(async (request, response) =>{
// code here is the same
});
After:
exports.webhookV2 = onRequest(
// Configuration options
{
retryConfig: {
maxRetryAttempts: 1,
minBackoffSeconds: 5,
},
},
async (request, response) => {
// code here is the same
});
Read more here: Source link


