This blog post introduces you to Serverless computing, OpenWhisk (a serverless, open source cloud platform that executes functions in response to events at any scale) and guides you in getting started with OpenWhisk on IBM Bluemix.
After writing a post on how to transform your idea into an app in minutes. I started thinking how about the compute part of the cloud? Will that be in minutes or less than minute or can it be milliseconds ?
Then I read this line in an article
With serverless computing there is no virtual infrastructure for the user to manage and the user is only billed for when their code is running, down to the nearest 100 milliseconds.
So, Let’s start with a question
What is Serverless computing?
Is there no server or a process at all? Nah!
Then where is our program or function running? There is no defined definition of Serverless Computing. Here’s one good definition which I think sums up every thing about Serverless Computing
Serverless computing refers to a model where the existence of servers is simply hidden from developers. I.e. that even though servers still exist developers are relieved from the need to care about their operation. They are relieved from the need to worry about low-level infrastructural and operational details such as scalability, high-availability, infrastructure-security, and so forth. Hence, serverless computing is essentially about reducing maintenance efforts to allow developers to quickly focus on developing value-adding code.
Serverless computing encourages and simplifies developing microservice-oriented solutions in order to decompose complex applications into small and independent modules that can be easily exchanged.
Serverless computing does not refer to a specific technology; instead if refers to the concepts underlying the model described prior. Nevertheless some promising solutions have recently emerged easing development approaches that follow the serverless model – such as OpenWhisk, AWS Lambda, Azure Functions and Google Functions.
A good introduction into the serverless programming model is available on Martin Fowler’s blog.
What is OpenWhisk?
OpenWhisk is an event-driven compute platform also referred to as Serverless computing or as Function as a Service (FaaS) that runs code in response to events or direct invocations.
- OpenWhisk hides infrastructural complexity allowing developers to focus on business logic.
- OpenWhisk takes care of low-level details such as scaling, load balancing, logging, fault tolerance, and message queues.
- OpenWhisk provides a rich ecosystem of building blocks from various domains (analytics, cognitive, data, IoT, etc.).
- OpenWhisk is open and designed to support an open community.
- OpenWhisk supports an open ecosystem that allows sharing microservices via OpenWhisk packages.
- OpenWhisk allows developers to compose solutions using modern abstractions and chaining.
- OpenWhisk supports multiple runtimes including NodeJS, Swift, and arbitrary binary programs encapsulate in Docker containers.
- OpenWhisk charges only for code that runs.
Getting Started with OpenWhisk
The OpenWhisk model consists of three concepts:
- trigger, a class of events that can happen,
- action, an event handler — some code that runs in response to an event, and
- rule, an association between a trigger and an action.
Develop in your Browser
Develop using the CLI
You can use the OpenWhisk command line interface (CLI) to set up your namespace and authorization key. Go to Configure CLI and follow the instructions to install it.
wsk: command not found
While using OpenWhisk CLI, If you are seeing this error on a Mac or Linux machine, Follow the below stepsOn your terminal, run the below command
- Move the downloaded wsk unix executable to /usr/local/bin or /usr/bin (preferable).
- Now run the command ‘wsk’ to see the below output
Using the OpenWhisk CLI
After you have configured your environment, you can begin using the OpenWhisk CLI to do the following:
- Run your code snippets, or actions, on OpenWhisk. See Creating and invoking actions.
- Use triggers and rules to enable your actions to respond to events. See Creating triggers and rules.
- Learn how packages bundle actions and configure external events sources. See Using and creating packages.
- Explore the catalog of packages and enhance your applications with external services, such as a Cloudant event source. See Using OpenWhisk-enabled services.
There are two awesome articles which will take you in-depth into OpenWhisk architecture (from Nginx to consul to kafka…..)
- Uncovering the magic: How serverless platforms really work! on Medium
- An Architectural View of Apache OpenWhisk on thenewstack
Where to go from here
Exposing OpenWhisk RESTful APIs with API Gateway
OpenWhisk NodeJS WebUI
- A curated list of awesome OpenWhisk things