Billy Lo

Jun 26, 2020

3 min read

Ep. 23 — Cloud functions Usage in production — Upsides & Downsides

Photo by ROMBO from Pexels

Over time, I have learned that the promises of most new and shiny platforms are legitimate, but the downsides are rarely as well understood until you roll up your sleeves to build something with it.

I gained some first hand perspectives recently after building cloud functions for two new Sidekick features.

  1. When was I here? — Sidekick now allows you to turn back the clock and see when you last visited a particular restaurant or landmarks. E.g. you can ask Sidekick: when was the last time I visited CN Tower? If you have location history enabled in Google, you can also import those into Sidekick so you can go back in time. (released this week on iOS)

Both features were built using Google’s Cloud Functions. But the lessons learned are generic enough to AWS Lambda or Azure Functions users.

Upsides (are they real?)

  • Zero installation to develop/test server side code? NO. Technically, you can write code using VSCode and directly deploy to the cloud, but the build/deploy/test/debug cycle would take too long (3+ minutes). I ended up spending time getting the emulators running locally, iterate locally, and then push to cloud for final verification.

Downsides (don’t let these surprise you)

  • Limits — Left, Right and Centre: They are, by definition, harmless until you exceed them. But there are LOTS of them; ranging from payload size, function counts, query string size, memory usage, storage usage, CPU time, frequency per region… the list goes on. It’s hard to keep them in your head so you can shape your solution to avoid running into brick walls. I ran into the 10Mb request size hard limit on Firebase CF and had to do some gymnastics to workaround it. See it for yourself: Limits for AWS Lambda, Azure Functions, Firebase CF, GCP. On top of the technical limits, you will also have to keep an eye on the billing limit when you exceed your cap on spending. Your function won’t run if it will exceed allocated budgets.

Current State (June 2020)

For some scenarios, Cloud Function may be your only option (e.g. code that respond to cloud events such as new files uploaded to bucket, database triggers. So, it’s a good time to build up knowledge on how to do it right.

Having said that, for my bread-and-butter http request/response services, I am staying with my existing toolset and runtime. IMHO, cloud function’s zero-configuration promise is not worth the new headaches it introduces.

Hope this helps, and until next time.