Run an application on a managed serverless platform

This article is part of the Introduction to IBM Cloud Code Engine series.

What is an application in IBM Cloud Code Engine

An application is a process that exposes an HTTP endpoint. You can use it as the backend for your web or mobile application, REST API server, and proxy application. Applications can also support the WebSocket protocol, which is useful for long running transactions such as a chat service. Of course, you can use it to implement any kind of microservices architecture.

IBM Cloud Code Engine applications combine all of the features that are needed by platform as a service (PaaS), containers as a service (CaaS), and serverless deployment models. If you have a container image, you can easily run it as an application on IBM Cloud Code Engine to serve incoming HTTPS requests with an intuitive user experience and without managing your infrastructure. Additionally, since IBM Cloud Code Engine has a pay-as-you-go model, you pay only for the infrastructure resources that your application actually uses.

Benefits of building applications in IBM Cloud Code Engine

IBM Cloud Code Engine applications are built for developers. The design principle is to allow a developer to focus only on the business logic for the application, but nothing else.

Easier user experience than Kubernetes

You might think, “I can run my application on Kubernetes.” IBM Cloud Code Engine is based on Kubernetes as the underlying container orchestration. Since Kubernetes is not built natively for developers, it requires you to take care of many technical aspects, such as network, infrastructure, and autoscaling. For example, to deploy an application on Kubernetes, you need to follow several steps to create your Kubernetes deployment, service, and ingress load balancing, and to enable autoscaling. In IBM Cloud Code Engine, you run one CLI command, ibmcloud code-engine app create --name helloworld --image docker.io/ibmcom/helloworld, to get everything set up properly, including running your container image, exposing an HTTPS endpoint, and setting up auto-scaling. And since IBM Cloud Code Engine is based on Kubernetes, advanced users are still able to use Kubernetes commands and APIs, such as kubectl get pods, if the IBM Cloud Code Engine abstractions get in your way.

Auto-scaling with scaling to zero

Most auto-scaling technology is based on CPU and memory monitoring, and there is not an easy way to scale to and from zero based on the actual HTTP traffic that reaches the application. For example, if an application is connected to an event source, the application must run only when an event happens so it is not necessary to run an application container all of the time. With the scale-to and scale-from zero capability, the application scales when needed and the user is charged only for the amount of time that the application runs. IBM Cloud Code Engine supports application instances that scale based on the HTTP request concurrency. The number of requests that are handled by a single application instance can be configured by the user. Learn more in the IBM Cloud Code Engine: Optimizing application scaling, latency, and throughput blog post.

Serverless model

IBM Cloud Code Engine is a serverless platform to run your applications. You focus on your application development instead of spending effort to maintain infrastructure, such as continuing to update your Kubernetes clusters and installing security patches. IBM Cloud Code Engine covers all of the infrastructure for you and provides an isolated and secure compute resource to run your application. You pay only for the resources that you use.

Route and endpoint setup

To build a web application, you typically think about the endpoint for your application. For example, you must get a public IP address, register a domain, order a domain certificate for HTTPS, configure a domain name system (DNS), and set up a load-balancing server. IBM Cloud Code Engine completes these infrastructure-related configurations for you. When you create a project in IBM Cloud Code Engine, a dedicated domain with an HTTPS certificate is enabled and created for your project. All applications in the project run on the dedicated domain, such as *.<project-id>.us-south.codeengine.appdomain.cloud. And if you want some of your applications to run with only internal access, IBM Cloud Code Engine also provide a local domain for it, which is only accessible to the workloads inside your project.

Observability

IBM Cloud Code Engine also provides operation capabilities for you to check log and metrics for your application by integrating with the IBM Log Analysis with LogDNA and IBM Cloud Monitoring with Sysdig services.

IBM Cloud Code Engine application introduction

IBM Cloud Code Engine is built on open source technology, including Knative and Istio. Knative helps to hide the complexity of managing HTTP-based workloads in Kubernetes. Knative is used to scale the application based on the number of concurrent in-flight HTTP requests. Istio acts as gateway, terminates the HTTPS request, and routes the HTTP traffic to the correct application and revision. In addition, IBM Cloud Code Engine supports you by providing the source code to create your applications and by integrating with the Tekton and Shipwright open source projects to translate source code into container images. This is represented in the following diagram.

Visual representation of how an application is built with IBM Cloud Code Engine

How to build applications in IBM Cloud Code Engine

IBM Cloud Code Engine provides simplified UI and CLI experiences for developers. To create an application, you just provide a container image as the mandatory input property. Of course, you are allowed to provide other optional properties, including CPU and memory to run your application, environment variables as application input, and application instances number range for scaling. Here is a CLI example to create an application:

ibmcloud code-engine application create --name helloworld --image docker.io/ibmcom/helloworld

The application might be successful within in tens of seconds depending on your image size. When done, the IBM Cloud Code Engine CLI returns a dedicated URL to access your application. The URL pattern is https://<application-name>.<project-id>.<region>.codeengine.appdomain.cloud.

IBM Cloud Code Engine also supports the Knative CLI, which means that you can continue to use the Knative CLI as before.

Summary

The IBM Cloud Code Engine platform is truly designed to help developers focus only on application development by managing the infrastructure and security automatically for you. Also, since IBM Cloud Code Engine pricing is a pay-as-you-go model, you pay only for the resources that you use, which can save costs. Get started by registering for a free trial of IBM Cloud Code Engine and deploying your first IBM Cloud Code Engine application.