April 2021 Online: Google Cloud Functions

Meetup #73. Please RSVP at Meetup.

We will be meeting online using this Google Meet at 6:30pm MST.

Talks

Google Cloud Functions

Matthias Stone gave a thorough introduction to Google Cloud Functions in Go. He covered what they are — event-triggered, serverless code (comparable to AWS Lambda) — why you'd use them (per-invocation billing, built-in scaling, minimal hosting fuss) and when not to (guaranteed latency, long-running jobs, persisted state or websockets, compute-heavy work). The talk explained the different trigger types, how to write an HTTP function (an ordinary http.Handler, minus func main and the main package), and how to deploy with the Console or gcloud functions deploy --runtime go113 --trigger-http. It then dug into the concurrency model — one request per instance, cold/warm starts, state not guaranteed between calls, and leaking goroutines/memory — plus lazy initialization, using muxers and middleware like Negroni, serving HTML, unit testing with httptest, the gcloud emulators, configuration via envconfig, and Google Cloud services (credentials, Firestore/datastores, logging, Secret Manager).

Key points:

  • Cloud Functions are event-triggered serverless code (like AWS Lambda).
  • Good for inconsistent loads and small independent pieces; bad for long-running or stateful work.
  • An HTTP function is just an http.Handler — drop main and the main package.
  • Deploy with gcloud functions deploy ... --runtime go113 --trigger-http.
  • One request per instance: cold vs warm starts, no guaranteed state, watch for leaks.
  • Lazy-initialize slow resources; unit-test with httptest and use emulators.
  • Integrates with GCP credentials, datastores, logging, and Secret Manager.

(slides)

News