Building Serverless Applications on Knative

Book description

Explore the theory and practice of designing and writing serverless applications using examples from the Knative project. With this practical guide, mid-level to senior application developers and team managers will learn when and why to target serverless platforms when developing microservices or applications. Along the way, you'll also discover warning signs that suggest cases when serverless might cause you more trouble than joy.

Drawing on author Evan Anderson's 15 years of experience developing and maintaining applications in the cloud, and more than 6 years of experience with serverless platforms at scale, this book acts as your guide into the high-velocity world of serverless application development. You'll come to appreciate why Knative is the most widely adopted open source serverless platform available.

With this book, you will:

  • Learn what serverless is, how it works, and why teams are adopting it
  • Understand the benefits of Knative for cloud native development teams
  • Learn how to build a serverless application on Knative
  • Explore the challenges serverless introduces for debugging and the tools that can help improve it
  • Learn why event-driven architecture and serverless compute are complementary but distinct
  • Understand when a serverless approach might not be the right system design

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Who Is This Book For?
    2. Background
      1. Containers
      2. Cloud Providers
      3. Kubernetes and Cloud Native
      4. Cloud-Hosted Serverless
    3. How This Book Is Organized
    4. Conventions Used in This Book
    5. Using Code Examples
    6. O’Reilly Online Learning
    7. How to Contact Us
    8. Acknowledgments
  2. I. The Theory of Serverless
  3. 1. What Is Serverless, Anyway?
    1. Why Is It Called Serverless?
    2. A Bit of Terminology
    3. What’s a “Unit of Work”?
      1. Connections
      2. Requests
      3. Events
    4. It’s Not (Just) About the Scale
      1. Blue and Green: Rollout, Rollback, and Day-to-Day
      2. Creature Comforts: Undifferentiated Heavy Lifting
      3. Creature Comforts: Managing Inputs
      4. Creature Comforts: Managing Process Lifecycle
    5. Summary
  4. 2. Designing from Scratch
    1. Setup for This Chapter
    2. A Single-Page App
      1. Bootstrapping a React App
      2. A Basic Web UI
      3. Packaging Our App
      4. Into the Cloud on Your Laptop!
      5. Under the Covers: How Requests Are Handled
      6. Continuing to Build
    3. Adding an API
    4. API Gateways and Composing an App
      1. Splitting an API into Components
      2. Augmenting a Proxy
    5. Complementary Services
      1. Key-Value Storage
      2. Object Storage
      3. Timers (Cron)
      4. Task Queues
      5. Workflows
    6. Summary
  5. 3. Under the Hood: Knative
    1. Infrastructure Assumptions
      1. Hardware and Operating System Management
      2. Scheduling and the Datacenter as a Computer
    2. Serving
      1. Control-Plane Concepts
      2. Life of a Request
      3. Autoscaling Control Loop
      4. Comparison with AWS Lambda
    3. Eventing
      1. Control-Plane Concepts
      2. Delivery Guarantees
      3. Life of an Event
      4. Ecosystem
      5. Comparison with Amazon SNS and Other Cloud Providers
      6. Comparison with RabbitMQ
      7. Comparison with Apache Kafka
      8. Eventing Summary
    4. Functions
    5. Summary
  6. 4. Forces Behind Serverless
    1. Top Speed: Reducing Drag
      1. Continuously Delivering Value
      2. Winning the (Business) Race
    2. Microbilling
      1. A Deal with the Cloud
      2. Clouding on Your Own
      3. What Happens When You’re Not Running
    3. The Gravitational Force of Serverless
      1. Implications for Languages
      2. Implications for Sandboxing
      3. Implications for Tooling
      4. Implications for Security
      5. Implications for Infrastructure
    4. Summary
  7. II. Designing with Serverless
  8. 5. Extending the Monolith
    1. The Monolith Next Door
      1. Microservice Extension Points
      2. Asynchronous Cleanup and Extension
      3. Extract, Transform, Load
    2. The Strangler Fig Pattern
      1. Experiments
      2. Dark Launch and Throwaway Work
    3. A Serverless Monolith?
    4. Summary
  9. 6. More on Integration: Event-Driven Architecture
    1. Events and Messages
      1. Why CloudEvents
      2. Events as an API
      3. What Does Event-Driven Mean?
    2. Event Distribution
      1. Content-Based Routing Versus Channels
      2. Internal and External Events
      3. Building for Extension with “Inner Monologue”
    3. Workflow Orchestration
      1. Long-Lived Workflows, Short-Lived Compute
      2. Workflow as Declarative Manifests
    4. Event Broadcast
      1. What’s So Tricky About Broadcast?
      2. Broadcast in Fast-Moving Systems
    5. Task Queues
      1. Task Queue Features
      2. Scaling in Time Instead of Instances
    6. Summary
  10. 7. Developing a Robust Inner Monologue
    1. Ambient Event Publishing
      1. The Active Storage Pattern
      2. Is Your Database Your Monologue?
    2. Scenarios for Inner Monologues
      1. Key Events
      2. Workflows
      3. Inner Monologues Versus RPCs
      4. Sensitive Data and Claim Checks
    3. How to Use an Inner Monologue
      1. Extending the Monolith: Workflow Decoration
      2. Scatter-Gather Advice
      3. Account Hijacking Detection
      4. Versioned Events, Unversioned Code
    4. Clouds Have Monologues Too
      1. Kubernetes: Only a Monologue
      2. Audit Log or Mono-Log?
    5. Summary
  11. 8. Too Much of a Good Thing Is Not a Good Thing
    1. Different Types of Work in the Same Instance
    2. Work Units That Don’t Signal Termination
    3. Protocol Mismatch
    4. Inelastic Scaling
    5. Instance Addressability and Sharding
    6. Summary
  12. III. Living with Serverless
  13. 9. Failing at the Speed of Light
    1. Meltdown
      1. Narrowest Bottleneck
      2. Feedback Loop
    2. Cold Start, Extra Slow
      1. The Race to Ready
      2. Avoiding Cold Starts
    3. Forecasting Is Hard
    4. Loopback
    5. Hotspots Don’t Scale
      1. Graphs and Focal Points
      2. Data Size
      3. Locking
    6. Exactly Once Is Hard
    7. Summary
  14. 10. Cracking the Case: Whodunnit
    1. Log Aggregation
    2. Tracing
    3. Metrics
    4. Live Tracing and Profiling
    5. APM Agents
    6. Summary
  15. IV. A Brief History of Serverless
  16. 11. A Brief History of Serverless
    1. 35 Years of Serverless
      1. inetd
      2. CGI
      3. Stored Procedures
      4. Heroku
      5. Google App Engine
      6. Cloud Foundry
      7. AWS Lambda
      8. Azure and Durable Functions
      9. Knative and Cloud Run
      10. Cloudflare Workers and Netlify Edge Functions
    2. Where to Next?
      1. AI
      2. Distributed and the Edge
      3. Beyond Stateless
    3. Summary
  17. Index
  18. About the Author

Product information

  • Title: Building Serverless Applications on Knative
  • Author(s): Evan Anderson
  • Release date: November 2023
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781098142070