Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Composing Serverless Apps With IBM Cloud Functions

DZone's Guide to

Composing Serverless Apps With IBM Cloud Functions

Get a sneak peek at IBM Cloud Functions' new Composer tool, designed to make developing serverless apps simpler and more flexible.

· Cloud Zone
Free Resource

Site24x7 - Full stack It Infrastructure Monitoring from the cloud. Sign up for free trial.

At Serverlessconf, IBM announced a new key capability (as an IBM Research preview) of IBM Cloud Functions. With the new tool Composer, apps can be created that contain multiple cloud functions. These apps coordinate the invocations of actions and the data flow. Compared to the previously available action sequences, the new functionality is much more flexible.

Cloud functions are typically rather simple and focussed on specific tasks, which is why people often refer to cloud functions as microservices. Cloud-native applications usually have many microservices. While the implementation of the microservices is rather simple, the key challenge is the orchestration layer above the microservices. That’s why frameworks like Kubernetes, with additions like Istio, have become very popular. With the new Composer tool, developers can now build apps that leverage multiple cloud functions and that require more complex, coordinated flows for end-to-end solutions.

Composer is an IBM Cloud Functions programming model for composing individual functions into larger applications. Compositions, informally named apps, run in the cloud using automatically managed compute and memory resources. Composer is an extension of the function-as-a-service computing model, and enables stateful computation, control flow, and rich patterns of data flow. Composer has two parts. The first is a library for describing compositions, programmatically. The library is currently available in Node.js. The second is a runtime that executes the composition.

Let’s take a look at a simple example. With the new Composer functionality, different functions can be invoked depending on the result of a previous function. The screenshot shows the new tool ‘fsh’ (functional programming shell), which displays the flow graphically.

cloud-functions-compose1

The apps (compositions) can be defined via JSON, which is executed by a runtime component. In addition to ‘if’, many other composition methods are supported.

cloud-functions-compose3

What I really like is the second approach to defining apps, which I think is more natural for developers. While you can define apps as JSON configurations, you can also write Node.js code that uses the Composer SDK, and you can use constructs as variables, try/catch statements, loops, data forwarding, and much more.

cloud-functions-compose2

The Node.js code is compiled into JSON, which is executed by the runtime. In order to handle the state of the apps, developers need to provision Redis datastores (see the documentation for details). The managed runtime, together with the datastore, allows hosting and running serverless apps.

To find out more, check out the quick start guide.

Site24x7 - Full stack It Infrastructure Monitoring from the cloud. Sign up for free trial.

Topics:
cloud ,ibm cloud functions ,composer ,serverless apps ,tutorial

Published at DZone with permission of Niklas Heidloff, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}