Open1

Cloud Run関数 (old: Cloud Functions) について

yukobyukob

Background

Cloud Functionやevent-drivenなプログラミングスタイルはCloud Run関数になるらしいので、変更点や今後恩恵を得られそうな機能について調査

Cloud Functions and its familiar event-driven programming model is now Cloud Run functions, complete with the fine-grained control and scalability that developers love about the serverless platform.

https://cloud.google.com/blog/products/serverless/google-cloud-functions-is-now-cloud-run-functions

また、Cloud Functions (1st gen)を使い続けている処理もあるため、移行のための調査についてもまとめる

What's changed

Cloud Function (2nd gen)は自動でCloud Run関数に変換される

Cloud Functions 2nd gen functions will automatically be converted into Cloud Run functions.

Cloud Function (1st gen)は引き続き利用できる

  • Cloud Runの機能を利用したければ、Cloud Run関数にupgradeする必要がある
  • Cloud Function (1st gen) API、gcloud、Terraformモジュールは引き続きサポートされる

1st gen functions will continue to be available as Cloud Run functions (1st gen). 1st gen functions need to be upgraded to Cloud Run functions before you can get full access to the underlying Cloud Run features. Cloud Run functions (1st gen) APIs, gcloud commands and Terraform modules (Gen1) will continue to be supported.

Cloud Run関数になると何が嬉しい?

GPUがサポートされるので、HugginFaceのモデルを使用した処理を従来のCloud Runのようにscalingすることが可能になるらしい

"The newly released Cloud Run functions with GPU support enables Python developers to use Hugging Face models without having to worry about infrastructure, GPU drivers or containers. Cloud Run's scale-to-zero and fast startup capabilities are a great match for developers looking at getting started with AI using HuggingFace models with just a few lines of serverless code” - Julien Chaumond, CTO, Hugging Face

scale-to-zero:

  • Kubernetesなどのコンテナオーケストレーションシステムにおける自動スケーリング機能の一つ
  • trafficがない場合はPod数を0に、trafficが発生したら必要に応じてauto scalingする

他にも、Cloud Runの恩恵を得られるらしい:

  • Multi-event trigger management on functions
  • High-performance Direct VPC egress
  • The ability to mount Cloud Storage volumes
  • Google-managed language runtimes, with automatic security updates on base images
  • Traffic splitting and revision control
  • Managed Prometheus and OpenTelemetry support with sidecar containers
  • Inference functions with NVIDIA GPUs