IBM Developer Day | Bengaluru | March 14th Register now
Get the code
View the demo
By Daniel Krook | Published July 18, 2017
Serverless platforms, like IBM Cloud Functions powered by Apache OpenWhisk, provide a runtime that scales up or down automatically in response to demand. This results in overall lower cloud resource consumption and a better match between business value gained and the cost of the resources that are used. This code pattern shows you how you can use Cloud Functions to map HTTP REST API calls to business logic functions that create, read, update, and delete entities, and how each API method handler action scales (and is billed) independently in direct correlation to the volume of requests.
This project shows how serverless, event-driven architectures execute code in response to demand from HTTP REST API calls. No resources are consumed until the API endpoints are invoked. When they are called, resources are provisioned to exactly match the current load.
It shows four IBM Cloud Functions (based on Apache OpenWhisk) that write and read data in a MySQL database, demonstrating how actions can work with supporting data services and execute logic in response to HTTP requests.
One function, or action, is mapped to HTTP POST requests. It inserts the supplied cat name and color parameters into the database. A second action is mapped to PUT requests to update those fields for an existing cat. A third action is mapped to GET requests that return specific cat data. A fourth action deletes a given cat data.
The Node.js runtime on IBM Cloud provides built-in whitelist of NPM modules. This demo also highlights how additional Node.js dependencies such as the MySQL client can be packaged in a ZIP file with custom actions to provide high extensibility.
Ready to put this code pattern to use? Complete details on how to get started running and using this application are in the README.
February 22, 2019
Before open source was cool, IBM was busy donating our code, establishing open licensing, pushing for open governance in the…
Get the Code »
Apache KafkaAPI Management+
Back to top