Thursday, November 30, 2023

Thoughts on how to move from Cloud Functions to Code Engine

Moving code and containers
IBM Cloud Code Engine is a fully managed, serverless platform to (not only) run your containerized workloads. It has evolved a lot since March 2021, the time when I published the blog post Migrating Cloud Functions Code to Code Engine. In 2021, there were only Code Engine apps and jobs. Earlier this year, Code Engine added support for functions(Function-as-a-Service, FaaS). Thus, in this post I am going to take a fresh look at that topic and discuss the options on how to move from Cloud Functions to Code Engine. 

IBM Cloud Code Engine deployment models

IBM Cloud Code Engine features three different ways to run your business logic. An app is a continously run process that answers to HTTP requests. A job runs to handle a task and then terminates. A function is a stateless code snippet that is invoked by an HTTP request and, after producing a response, terminates. Moreover, jobs usually run significantly longer than functions (“batch processing”). 

There are many more characteristics that help distinguish between apps, jobs, and functions. In short, apps are a good fit if you want to craft a REST API or deploy a web application with backend / frontend functionality. You have full control over the HTTP server and its resources. Jobs, on the other hand, are long-running processes that do not require any user interaction. They could be typical batch activities, analytics processing, or even AI model training. Last, functions can react to incoming HTTP requests very fast. They serve well low latency use cases like chat bot integrations or webhooks. In contrast to apps, you do not and cannot define and configure the HTTP server.

Function use cases and properties

When coming from Cloud Functions, you might have experienced that there is not that one type of function, but there are many use cases supported by Cloud Functions. Similarly, a function may have different attributes that are important depending on the case.

  • The invocation or start-up time (cold start) might be important, leading to an overall short response time.
  • In other cases, the cost (billing) might have been the competitive factor.
  • The simplicity and agility, caused by a function as unit for development and deployment in a DevSecOps process leads some projects to opt for functions.

Often, it is a combination of the above to prefer functions (FaaS) over other runtime or compute options.

Moving from Cloud Functions to Code Engine, the following function characteristics need to be taken into account when deciding to on an app, a job, or a Code Engine function.

  • Is an http endpoint needed to invoke the code?
  • Is the processing triggered by an event?
  • What programming language is used for the existing function and how big are the required libraries?
  • How long does the processing take, what compute resources are needed, is parallel processing desired?
  •  …

Background reading

The guide Migrating IBM Cloud Functions to Code Engine has a detailed overview with Code Engine app, job, and function characteristics. They help you to select the best entity for your existing workload. Additionally, the current Code Engine function limitations and the general Limits and quotas for Code Engine need to be taken into account. Last but not least, the section Migrating IBM Cloud Functions Actions to Code Engine Functions FAQ might help answer remaining questions on how to move from Cloud Functions to Code Engine.

If you have feedback, suggestions, or questions about this post, please reach out to me on Twitter (@data_henrik), Mastodon (@data_henrik@mastodon.social), or LinkedIn.