Programming Languages / Serverless

IBM Delves into Serverless Function Orchestration with the Open Source Composer Tool

10 Jan 2018 8:15am, by

As developers grow increasingly comfortable with using cloud-based serverless or “function-as-a-service” services,  they may be finding that coordinating their collection of functions is, in itself, a growing task.

To this end, IBM Research has developed new software, called Composer, that provides a way to easily orchestrate the operation of many serverless jobs running on IBM Cloud Functions service or IBM’s open source serverless software Apache OpenWhisk. Much like Kubernetes provides a way to orchestrate the operations of large number of containers, so too can Composer can link together serverless functions into complex applications.

“Building complex applications is more than just writing simple functions. You may have dozens of functions,” said Paul Castro, a research staff member from IBM Research, who worked on Composer. The developer would have to find a way to “stitch these functions together,” namely by specifying the control flow of how the functions work together, as well as establish the conduits that would be needed to pass the data around. Moreover, developers will be needing a way to show how multiple functions, and other resources, are composed together.

 

Before Composer, developers would have to write out the coordination code as client-side scripts, or embed the control flow within the functions themselves, Castro said. Composer differs from others, such as Microsoft’s Azure Functions, in that it does not rely on functions to call out to other functions directly. This approach abstracts out the flow for the entire application.

“We want to expose that logic to make it very crystal clear as to what is happening,” Castro said.

Composer offers a “simple programming model,” one based on JSON-based parameters, to specify how the functions work together, Castro noted. The model supports if-then statements for logic branching, function chaining, error-catching functionality. There are also constructs to manage data flow, such as the ability to send data to multiple endpoints.

With composer, the developer can build an entire app from stand-alone functions, including the logic flow itself, Castro said. The setup supports all the languages recognized by either OpenWhisk or IBM Cloud Functions: JavaScript, Swift, Java, PHP, Python, or any code encapsulated in a Docker container.

The compositions themselves are written in JavaScript. Here’s a simple example from an IBM blog post:

composer.sequence(                // programmatic composition
  ‘currentTemperature’,           // call cloud function or API
  composer.if(                    // conditional control flow
    result => result.temp < 60,   // mix inline JavaScript
    ‘turnOnHeat’)                 // interface to 3rd party services
)

Composer has two parts. One is a library for describing the compositions, currently rendered in Node.js. To help work with the “compositions,” IBM also released the IBM Cloud Functions Shell (fsh), an Electron-based visual shell development tool that runs on the developer’s machine. It offers the ability to get visualizations of the compositions and runtimes, along with historical performance graphs, and the ability to drill down to the source code.

The IBM Cloud Shell showing the control flow.

“We see this as an easier way to develop functions in the cloud without having to do any context switching. They can stay in one place to create their compositions,” Castro said. This approach also offers potential cost-savings, since functions don’t need to be called into run-time until they are needed, as opposed to keeping them idle on a cloud service waiting for work from elsewhere to come in.

The JavaScript composition of an app, a collection of function calls, is uploaded to the IBM Cloud Functions or OpenWhisk and rendered into a finite state machine through a component called Conductor, so it can execute itself in the cloud as a serverless function.

Composer is a reference implementation of the overall programming model, which like, with IBM’s open source release of OpenWhisk itself, IBM is seeking feedback on from the community. The company hopes others will develop bindings for other languages and run-times for the software.

“We’d like people to try it out and offer feedback as to how to make this better,” Castro said.

Microsoft is a sponsor of The New Stack.

Feature image by Jussara Romão on Unsplash.


A digest of the week’s most important stories & analyses.

View / Add Comments

Please stay on topic and be respectful of others. Review our Terms of Use.