Learning Apache OpenWhisk
by Michele Sciabarr
Copyright 2019 Michele Sciabarr. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Editors: Virginia Wilson and John Devins
- Production Editor: Nan Barber
- Copyeditor: Christina Edwards
- Proofreader: Rachel Head
- Indexer: Ellen Troutman-Zaig
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Rebecca Demarest
Revision History for the First Edition
- 2019-07-01: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781492046165 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. Learning Apache OpenWhisk, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
The views expressed in this work are those of the author, and do not represent the publishers views. While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-492-04616-5
[LSI]
Foreword
Amazon Web Services changed the cloud computing landscape in November of 2014 when it launched a new service called Lambda. It offered developers the intriguing possibility of processing thousands of events concurrently, simply by registering functions as event handlers. With Lambda, functions execute on-demand and scale instantly and costs are proportional to actual resource utilization. This new model of computing was dubbed serverless because it let developers eschew all aspects of server-side development and operationsincluding infrastructure management, resource provisioning, and scaling.
Amazon showed that in the era of managed infrastructure and services, cloud providers can free developers from low-level operational burdens and let them focus on what matters most: delivering real business value to their organizations. Serverless computing is the foundation of a cloud-native transformation that is ongoing in the industry. It is the way cloud applications are being built and will largely be built in the future. There are now more than a trillion functions processed every month on Amazon alone for a wide variety of applications from IoT, web applications, machine learning, and high-performance computing.
At IBM Research, my group took notice of the Lambda announcement, and we quickly realized the value of the serverless promise. So in February 2015, we set out to build a serverless platform for the IBM Cloud. The project was code-named Whisk, as in to move nimbly and quickly. It was later branded OpenWhisk when we open-sourced the code to GitHub, nearly a year to the day from our first commit. Today, the project is part of the Apache Software Foundation Incubator and its the premiere open-source alternative to Amazons Lambda. Apache OpenWhisk is ready for Enterprise workloads and offers a powerful programming model for building entire serverless applications. It powers serverless product offerings from IBM and Adobe, and its used in private deployments in some of Asias largest mobile and internet providers. The Apache OpenWhisk community consists of more than 215 contributors from around the world, and is among the top 30 Apache Foundation projects ranked by their GitHub stars. Many of the top OpenWhisk contributors are now also shaping the future of other emerging serverless platforms such as Googles Knative project, which aims to bring a serverless experience to the increasingly popular Kubernetes platform.
In this book, Michele Sciabarr delivers a thorough exposition of Apache OpenWhisk tailored to the needs of developers and operators. For developers eager to adopt a serverless methodology, this book explains the emerging computational patterns and current limitations. It also illustrates several examples of applying the technology to solve real-world challenges. For operators who want to deliver a serverless experience for their organizations, Michele carefully reveals the OpenWhisk architecture, and provides a go-to guide for deployment and operations, particularly for a Kubernetes-based deployment.
Michele draws on his own contributions to the Apache OpenWhisk project in writing this book. His work has dramatically improved the performance of serverless functions developed in Go, PHP, Python, Swift, and more. His insightful and practical approach is well-suited to the developer who wants get up to speed quickly in harnessing the power of serverless computing.
For those of us at the frontier of the serverless journey, there is no doubt that we are witnessing the dawn of a new Cloud Computer, with functions at the cornerstone of a new instruction set architecture. This model of computing is powerful and disruptive, and yet much work remains to be done. History has shown that as new computer abstractions emerge, innovation follows.
Rodric Rabbah
CTO and Cofounder Nimbella Corporation
April, 2019
Preface
This book is for developers who want to learn to use Apache OpenWhisk, a mature, multilanguage, serverless development platform. It provides the knowledge needed to build complex, well-structured, polyglot serverless applications that can be deployed in any cloud or even on-premises.
Why Serverless?
For a long time, companies built their own data centers and bought hardware to install their web applications, mobile backends, or data processing pipelines. But the high costs of building and maintaining data centers eventually led to people renting servers from third parties to reduce costs. Servers are frequently partitioned to virtual machines, allowing businesses to pay only for what they need (as opposed to renting a whole server). Eventually, this concept evolved into what today we generically call the cloud. The cloud at its core is mostly a server on demand service. Modern cloud providers offer a wide range of services but have also become increasingly complex. In particular, one source of this complexity is the need to provision and manage servers. Servers are cattle not easy to raise. They require continuous care and control and must be monitored, cleaned, updated, and occasionally destroyed and rebuilt. Like cattle, they also tend to grow and multiply quickly.
Developers want to forget the server (serverless) and develop their application as native citizen of the cloud (cloud-native). The focus here is to push the burden of managing the servers onto the shoulders of a platform deployed in the cloud. Most software developers want to upload their code and immediately have it up and running.
As a result, all the major cloud providers now offer some form of Function as a Service that hides the servers and only needs the code to runin short, a way to use their cloud serverless.