When we ask developers why they choose Cloud Functions, “simplicity” comes up a lot: write a few lines of code, deploy and… voila! You’ve got a serverless, auto-scaling, pay-per-use function running on Google Cloud.
A big part of that simplicity comes from being able to write Cloud Functions in your favorite programming language. That’s why we’re excited about our recent language support announcements at Google Cloud Next ’19:
Python 3.7, Go 1.11 and Node.js 8 runtimes are now generally available.
Node.js 10 runtime is now in public beta.
Let’s take a closer look at one of the generally available runtimes:
Serverless + Python on Cloud Functions
Over the past six months, we’ve spoken to many established and up-and-coming customers who have used these runtimes to build on Cloud Functions. One customer, infarm, uses Cloud Functions and Python 3 to support its distributed network of efficient vertical farms:
The event driven interface was an especially good fit for our alerting stack, taking in more than 2.6 million plant- and farm-related measurements per day to prevent our crops from being affected by potential incidents. We rely on Google’s monitoring and alerting capabilities to monitor 400+ farms across Europe. – Nicolas Delaby, Lead Engineer, infarm
By opting for serverless on Google Cloud, infarm can focus on its mission: to help cities develop self-sufficient food production while improving agricultural safety, quality, and lowering their environmental footprint. Notice how that mission doesn’t include “managing my server infrastructure” or “learning new programming languages”?
Use Cloud Functions to process IoT data
Python and data processing go hand-in-hand. A common architectural pattern that we’ve observed among customers that use IoT devices is to have each device push sensor readings to a message bus. For example, one of infarm’s modular farms might have multiple IoT devices, each sending sensor data as messages to a Cloud Pub/Sub topic. When a message is delivered to the topic, it triggers a function, which performs a task. That task can be as simple as redirecting messages to a persistent datastore like Cloud SQL, to enriching data before inserting it in BigQuery, to performing complex processing.