Table of Contents
Technological revolution is moving at a very fast pace and pressurizing organizations to use new technologies among tough competition. It becomes essential to cope up with demand and maintenance from technology perspective and expand business offerings or services. Transition from on premises to cloud computing had given rise to serverless computing phenomena to revolutionize businesses.
In today’s topic we will learn about serverless computing, how applications are built and deployed using IBM cloud functions, cost and performance benefits of serverless computing.
Related: AWS Lambda vs Azure Functions vs Google Cloud Functions
What is Serverless Computing?
The basis of serverless computing is the original cloud business model, where physical infrastructure belongs to the cloud provider and virtual systems are leased out to the customers. However, this model requires to lease a pre-decided amount to be paid over a set period such as annual subscription cost. In a gradual shift towards enterprise cloud computing a new model emerged where organizations only pay for the memory an application code consumes and the amount of time. Serverless is a cloud computing model which performs automatic execution of computing resources, scaling resources up and down and scaling them to zero if no consumption.

Primary concern of enterprises is to reduce cost and effort required in managing and maintenance of servers. It is a daunting task for enterprises to manage on-prem hardware. In serverless computing instead of opting for a cloud space or hardware for on prem setup, developers can choose to go serverless to access memory on a pay-as-you-go basis. It saves cost and allows developers to build and design applications with more agility. It eliminates the need for managing IT infrastructure tasks such as operating system maintenance, server provisioning, patching, upgrades etc.
Advantages of Serverless Computing
- Enablement of development teams to focus only on writing code and free from managing underlying infrastructure, removing complexity and more time to innovate and optimize front end application
- Serverless model let resources scale quickly and also being a multilingual environment it let developers choose the language and framework they want to use (Python, Java, Node.JS)
- No need to spend on keeping hardware up to date reduction in infrastructure and operational costs drastically
- Reduction in latency time between servers interacting faster and experience which is frictionless
- Pay-as-you-go model is easy for usage monitoring inline with business requirements
- Serverless architecture can be scaled up/ down to zero, the start-up latency is not noticeable which near zero
IBM Cloud Function – Build and Deploy Applications
Serverless architecture uses cloud services to execute in response to events. IBM cloud functions is a serverless platform to allow developers to build and deploy code in different languages such as Java, Node.js and Python. To deploy serverless applications using IBM cloud function and IBM WebSphere application server developers can use IBM cloud function Command line interface (CLI) to create and manage their required functions. Figure 1 below depicts a typical deployment of IBM cloud functions setup.

To create a Java function using IBM cloud function CLI, below command will be used by the developer.
ibmcloud fn action create ownJavaFunction --jar target/ownJavaFunction.jar --main com.example.OwnFunction
Once the function is created using the JAR file located at ‘target/ownJavaFunction.jar’ and the main class ‘com.example.OwnFunction’
This function can be triggered by an event, such as an HTTPS request or on a task completion. For example, to trigger function with an HTTPS request, developer could use below command
ibmcloud fn api create /ownApi /ownJavaFunction post ownJavaFunction --response-type json
This command will create an API endpoint ‘ownApi’ which invokes ‘ownJavafunciton’ when it receives a post request. The response of the function will be returned in JASON format.
To deploy serverless application using WAS and IBM cloud function follow below steps:
Step 1
Install IBM cloud function CLI and authenticate using IBM cloud credentials
Step 2
Build and package application as JAR file. Including the dependencies and main class which contains code for serverless function.
Step 3
Use IBM cloud function CLI to create function. Example create Java function with below command
ibmcloud fn action create ownJavaFunction --jar target/ownJavaFunction.jar --main com.example.ownFunction
Step 4
Create an API endpoint with function, this will trigger function with HTTPS request. For example, create API function for POST request use below command
ibmcloud fn api create /myApi /ownJavaFunction post ownJavaFunction --response-type json
Step 5
Test function by sending HTTPS request to API endpoint, response from function has to be in JSON format
Step 6
To update function rebuild JAR file with updated code and use IBM cloud function CLI to update it. For example, use below command to update ‘ownJavafunciton’ action
ibmcloud fn action update ownJavaFunction --jar target/ownJavaFunction.jar --main com.example.ownFunction