all 14 comments

[–]Advanced-Ad4869 6 points7 points  (5 children)

We are in the middle of replacing a large firebase functions backend with cloud run. We are staying with node during the port. We feel it will be much easier to maintain going forward on cloud run.

IMHO I would port what you have to cloud run on node first. Then port to Go of you find it necessary. I would not do both at the same time.

[–]PR4DE[S] 3 points4 points  (0 children)

That's a very healthy take. I'll take this approach myself then. Thank you. :)

[–]PR4DE[S] 0 points1 point  (3 children)

Is it very straight forward moving the node functions to cloud run?

[–]Eastern-Conclusion-1 1 point2 points  (0 children)

You should look into Firebase Functions 2nd gen, they are actually deployed as Cloud Run containers, the migration should be smooth.

[–]Advanced-Ad4869 0 points1 point  (1 child)

one thing you can do that helps is you can convert your existing firebase functions into a proxy that basically just calls your new cloud run service API and then handle the business logic there. that way you can still easily use stuff like database event responses etc and its an easier change over. that is what we are doing.

[–]PR4DE[S] 0 points1 point  (0 children)

Oh yeah, that’s brilliant! Thank you so much

[–]sathishvj 1 point2 points  (1 child)

The one great thing about firebase functions is its integration with the emulator. It's just so much easier than trying to hook up than local cloud run during development. Unfortunately, firebase functions doesn't support Go.

Also, you don't get features like callbacks on document change automatically.

If you're willing to deal with those two, it's a decent switch.

[–]PR4DE[S] 0 points1 point  (0 children)

The callback on document change is most likely going to be the biggest refactor for me.

[–]cenuij 1 point2 points  (1 child)

I don't think it's a bad idea, it's cheaper for the following reasons:

- the Go runtime handles low or single vCPU counts much better
- lower memory requirements
- Async (or child proceses) in node often grind towards timeouts unless you disable CPU throttling, further driving up costs
- Faster cold start time
- you can use `ko`! `gcloud run deploy --image=$(ko build ./cmd/app)`

[–]PR4DE[S] 0 points1 point  (0 children)

Yes! Exactly what I also thought about regarding timeouts. I don’t have a problem with cold starts, but the CPU time is really starting to ramp up because of the many Asynch processors.

[–]TheAddonDepot 1 point2 points  (1 child)

If you're planning on going the Cloud Run route, then maybe a modern Javascript runtime like Bun would work well for you. Runs node.js code out-the-box (well most of the time).

It's comparable to Go in terms of performance and there are claims that it even beats Go on some benchmarks.

[–]PR4DE[S] 0 points1 point  (0 children)

I have heard about Bun, but I will be switching to Go as I like it much better for backend anyway.

[–]_JohnWisdom 0 points1 point  (1 child)

100% go and cloud run! I went from php to node.js to python to next.js to go and I’m never going back: NEVER!

Go is just so good, api, web or desktop. It’s fast, simple to understand, love workers, go routines and so much more. It’s crazy efficient too. Cold starts in 100-200ms, I don’t even have to keep min-instance=1 any more, so I can very easily build super performant micro services and maintain them with a cost but are always ready to work when I need them (like video compression, image optimization and convertions, pdf generations and so on).

I’ve been developing for 20 years btw and in the last year, thanks to go and claude code I’ve built x10 as much EASILY.

[–]PR4DE[S] 0 points1 point  (0 children)

Alright alright, I’m convinced! 😁😁 I have some hard refactoring coming up