Building Serverless Applications with Google Cloud Run

Ebooks are available and paperbacks are shipping (where to buy)


"I’ve been fortunate enough to be a part of the Google team that helped create Knative and bring Cloud Run to market. I’ve watched Cloud Run mature as a product over the years. I’ve onboarded thousands of customers and I wrote a framework to help Go developers build Cloud Run applications faster--and even I learned a thing or two from this book. What took me three years to learn, Wietse delivers in less than a dozen chapters."
— Kelsey Hightower, Principal Engineer at Google Cloud

Where to Buy

Ebooks are available here:

The paperbacks are shipping, check your favourite (local) bookstore for a delivery estimate. You can buy directly from O'Reilly at a discount if you are in the US or Canada

About the Book

If you have experience building web applications on traditional infrastructure, this hands-on guide shows you how to get started with Cloud Run, a container-based serverless product on Google Cloud. Through the course of this book, you'll learn how to deploy several example applications that highlight different parts of the serverless stack on Google Cloud. Combining practical examples with fundamentals, this book will appeal to developers who are early in their learning journey as well as experienced practitioners (learn what others say about the book).

Who this Book is For

If you build, maintain or deploy web applications, this book is for you. You might go by the title of a software engineer, a developer, system administrator, solution architect, or a cloud engineer. I carefully balance hands-on demonstrations with deep dives into the fundamentals so that you’ll get value out of it whether you’re an aspiring, junior, or experienced developer.

I tried to stay as programming language agnostic as possible and I use Go for the code listings, because it is easy to read if you haven't worked with it before.

Full Chapter Outline

Chapter 1 gives a general overview of what a serverless application is, introduces you to Google Cloud and their serverless products without going too much in depth. If you are new to Google Cloud, this will be a great introduction.

Chapter 2 is a hands-on introduction to Cloud Run. I’ll show you how to get started with Google Cloud and deploy your first Cloud Run service. While the first part of the chapter focuses on using Cloud Run, in the second part I explain the runtime characteristics of Cloud Run and how they influence the way you build your application. I’ll also compare Cloud Run with the other serverless runtimes on Google Cloud: App Engine and Cloud Functions.

In Chapter 3 you’ll find a thorough introduction to application development with containers. In this chapter I show you how to run containers on your local machine with Docker, create your own container images (with and without Docker), and dive into the fundamentals of containers.

The containers on Cloud Run are disposable. This requires you to store data you need to persist beyond the lifetime of a single request in a database or another downstream system. In Chapter 4 I dive into the managed product Cloud SQL (managed relational databases such as MySQL and PostgreSQL), in Chapter 5 I follow up with MemoryStore (Redis). I discuss scalability and reliability, as Cloud Run can scale to 1,000 containers very fast.

Especially if you are building a more serious application, you’ll want to make sure that every Cloud Run service in your system only has the permissions to do exactly what it needs to do. In information security, this is also known as the principle of least privilege: it helps to reduce the impact of a vulnerability in one part of the system. This is why I introduce you to Cloud Identity and Access Management (IAM) in Chapter 6.

Most applications have the need to schedule tasks to be executed later, either immediately after handling an HTTP request or at a scheduled time. In Chapter 7 I introduce you to Cloud Tasks when I cover patterns to use for task scheduling.

In Chapter 8 I’ll show you how to work with Terraform, an infrastructure as code (IaC) tool. Terraform lets you recreate your entire project using one command, which proves useful if your application grows beyond “Hello World”. If you are still getting started with building applications, you might want to skip this chapter and the last two chapters for now, to come back to them later.

I want to make sure that you have proper visibility over what is going on in your system when you go live for end users. This is why I cover structured logging and tracing in Chapter 9. Doing this right is fundamentally important when you run a system in production.

Finally, I move beyond the day-to-day concerns and think about the future in Chapter 10. If you build your application on top of a vendor-controlled platform, you should consider portability.


"This is the most comprehensive, yet approachable guide to getting started with Cloud Run (and its vast array of accompanying tools and technologies) that currently exists - no small feat for a technology that's seen rapid evolution over the past 12 months. From introducing the concept of containers, to discussing the real-world considerations when deploying Cloud Run as part of a microservices-based architecture, Wietse has written a book that will appeal to both newcomers to Google Cloud and veteran developers alike."
Chris Tippett - Principal Consultant at Servian (UK)
"Wietse Venema's book goes into significant technical depth while also keeping the reader grounded with realistic scenarios. I had the opportunity to review it, and look forward to purchasing a copy of my own so that I can read it again. Google Cloud Run may be the most interesting compute platform you'll use in the years ahead, and this book will help you build up the knowledge you need to successfully use it."
Richard Seroter, Director of Outbound Product Management at Google Cloud
"What can I say... this guy definitely knows what he's talking about. He is as enthusiastic about the subject as most people are about little puppies, and manages to explain it in a way that anyone can understand it. His diagrams are a strong part of the book. They help you understand topics that can be daunting and difficult to comprehend, especially for junior backend developers like myself. Go buy this book, it will make your life running in the cloud a whole lot easier!"
Femke Buijs - Software Engineer at Mollie
"Get ready for what I believe is going to be the de facto reference book for Google Cloud Run. Wietse Venema explores and explains every facet of the product and goes into details of building production-grade serverless apps. As a Cloud Run Product Manager, I helped review every chapter for accuracy."
Steren Giannini, Cloud Run Product Manager at Google Cloud
"Wietse has an engaging and personal style that makes this book a pleasure to read. What I like especially, is that apart from essential knowledge about Cloud Run, it also contains plenty of anecdotes, best practices and useful advice to make you a better application developer. Highly recommended!"
Robbert Brak - Principal Software Engineer at 4me
"Developers looking to future proof their career for the next decade will love this book because: #1 It is a practical, easy to read and concise guide on Cloud Run (the technology that finally closes the gap between Serverless and Containers). #2 The author covers a broad set of managed services on Google Cloud Platform to help you become productive quickly (even if you're new to GCP). #3 If you're skeptical about vendor lock-in, you will appreciate the section on how to take your serverless containers and "move out" of the Google Cloud."
Daniel Zivkovic, Solution Architect and Organizer of Serverless Toronto User Group
"I loved Wietse's book, particularly how he covered important nuances such as at least once delivery with Cloud Tasks, and a great explanation of the issues around default service accounts which is a problem often overlooked. The book is written in a very hands on practical style with a wide range of essential topics covered which means this book could be used as a cornerstone for understanding serverless on Google Cloud. I look forward to using this book as a reference in my upcoming projects."
Simon Lane, Lead Cloud Engineer at Refinitiv
"Un libro de referencia si necesita crear y desplegar aplicaciones serverless con Google Cloud Run. El contenido es completo, bien escrito y cuenta con muchos consejos, ideas, sugerencias y excelentes ejemplos (código fuente en GitHub). Mis capítulos favoritos son: "Building Containers", "Working with a Relational Database", "Service Identity and Authentication", "Working with HTTP Sessions". Un gran libro con impacto real en mi trabajo diario"
This book is essential if you need to build and deploy serverless applications with Google Cloud Run. The content is comprehensive, well-written, and features useful advice, insights, tips, and excellent examples (source code on GitHub). My favorite chapters are: "Building Containers", "Working with a Relational Database", "Service Identity and Authentication", and "Working with HTTP Sessions". This is a great book with a real impact on my day-to-day work.
Silviu Daniel Eftimie, Principal Cloud Developer at Mediabrands Spain

About Wietse Venema

I'm a software engineer. If I'm not helping teams to build scalable and reliable software, I'm figuring out how things work so I can be a better engineer and teacher. I work at to help companies build what's next in the public cloud.

I'm proud to be the name twin (not family) of the famous Wietse Venema, who created Postfix.

I love to hear from you! Follow me on and connect with me on