Google Cloud supports Ruby on Cloud Functions
Google Cloud recently announced the Ruby on Cloud Functions public preview. The open source functions framework for Ruby supports both HTTP functions and CloudEvent functions.
Introduced by Google in 2017, Cloud Functions is a serverless runtime environment for building and connecting cloud services. Functions are executed in language-specific runtime environments and can be written in Node.js, Python, Go, Java, .NET, and now Ruby. The runtime environment includes the runtime, the operating system, and a library that calls the function. For Ruby, the runtimes supported in preview are Ruby 2.6 and Ruby 2.7. Daniel Azuma, Senior Developer Relations Engineer at Google, explains how developers can use them:
You can write HTTP functions to respond to HTTP events and CloudEvent functions to process events from various cloud and Google Cloud services, including Pub / Sub, Cloud Storage, and Firestore.
In a separate article, “Designing a Ruby Serverless Runtime“he shares some of the design choices behind the product and the approach to five different components: function syntax, concurrency and lifecycle, testing, dependencies, and standards. He concludes:
Serverless is a fundamentally different way of thinking about compute resources, and as an industry we are still very early in our understanding of the implications. When my team designed the Ruby runtime for Google Cloud Functions, we were aware of how the serverless paradigm interacts with our normal Ruby practices. In some cases, like with testing, it encourages us to double down on the right parts of the Ruby culture. In others, such as expressing and noting a function in a language that does not strictly speaking have them, it challenges our ideas of how to present the code and communicate its intention.
The open source functions framework for Ruby is available at GitHub. In addition to Cloud Functions, it supports Cloud Run, any Knative-based environment and local development machines.
JK Gunnink, senior consultant at Mechanical Rock, wrote a guide for automated testing and deployment of Ruby functions on Google Cloud. Google isn’t the first cloud provider to support the language on a serverless framework. Ricardo Siqueira de Oliveira Leite, software engineer at VTEX, tweeted two years ago:
We want FaaS (Function as a Service) for Ruby! This is an online petition to show that the Ruby community is ready to go serverless and show Function as a service provider.
A petition which has been signed by over 1600 developers and is now a forum for Ruby enthusiasts. Two years later, with the support of AWS Lambda since 2018 and now on Google Cloud, the community has reached the goal. Ken collins, AWS Serverless Hero and Senior Engineer at Custom Ink, launched earlier this year Lambda containers with rails. Azure Functions currently supports seven languages but Ruby is not one of them.
A ruby Quick Start Guide is available for Google Cloud Functions and, like other support languages, GCP free level including two million calls and an allocation of 400,000 GB-seconds and 200,000 GHz-seconds of compute time.