Programming AWS Lambda: Build and Deploy Serverless Applications with Java

Programming AWS Lambda: Build and Deploy Serverless Applications with Java

Programming AWS Lambda: Build and Deploy Serverless Applications with Java
Автор: Chapin John, Roberts Mike
Дата выхода: 2020
Издательство: O’Reilly Media, Inc.
Количество страниц: 362
Размер файла: 16.2 MB
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

Foreword....6

Preface....8

About This Book....8

Why We Wrote This Book....8

Who This Book Is For....9

Why You Need This Book....10

Using the End-of-Chapter Exercises....10

Conventions Used in This Book....11

Using Code Examples....12

O’Reilly Online Learning....13

How to Contact Us....13

Acknowledgments....14

1. Introduction to Serverless, Amazon Web Services, and AWS Lambda....16

A Quick History Lesson....16

The Cloud Grows....18

Enter Serverless....19

Backend as a Service....19

Functions as a Service....20

Differentiating Serverless....21

What Is AWS?....22

Types of Service....23

Capacity....23

Who Uses AWS?....25

How Do You Use AWS?....25

What Is AWS Lambda?....26

Functions as a Service....27

FaaS as Implemented by Lambda....28

Why Lambda?....30

What Does a Lambda Application Look Like?....31

AWS Lambda in the Java World....35

Summary....36

Exercises....37

2. Getting Started with AWS Lambda....39

Quick Guide to the AWS Console....39

Regions....40

Identity and Access Management....42

Lambda Hello World (as Quickly as Possible)....42

Setting Up Your Development Environment....46

AWS Command Line Interface....46

Java Setup....53

AWS SAM CLI Installation....55

Lambda Hello World (the Proper Way)....55

Creating Your First Java Lambda Project....56

Building Hello World....57

Creating the Lambda Function....58

Summary....61

Exercises....62

3. Programming AWS Lambda Functions....63

Core Concepts: Runtime Model, Invocation....63

The Lambda Execution Environment....64

Invocation Types....65

Introduction to Logging....69

Input, Output....71

Lambda Function Method Signatures....71

Configuring the Handler Function in the SAM Template....73

Basic Types....73

Lists and Maps....75

POJOs and Ecosystem Types....77

Streams....79

Context....81

Timeout....83

Memory and CPU....85

Environment Variables....90

Summary....91

Exercises....92

4. Operating AWS Lambda Functions....93

Build and Package....93

Uberjars....94

Assembling a ZIP File....95

Reproducible Builds....101

Deploy....103

Infrastructure as Code....104

CloudFormation and the Serverless Application Model....105

Security....108

The Principle of Least Privilege....109

Identity and Access Management....111

Summary....118

Exercises....118

5. Building Serverless Applications....120

Lambda Event Sources....121

Writing Code to Work with Input and Output for Event Sources....121

Configuring a Lambda Event Source....126

Understanding Different Event Source Semantics....127

Example: Building a Serverless API....129

Behavior....129

Architecture....130

Lambda Code....133

Build and Package Using the AWS SDK BOM....144

Infrastructure....146

Deployment....149

Example: Building a Serverless Data Pipeline....154

Behavior....155

Architecture....155

Lambda Code....160

Build and Package Using Multiple Modules and Isolated Artifacts....167

Infrastructure....174

Deployment....177

Summary....179

Exercises....180

6. Testing....182

The Test Pyramid....182

Unit Tests....183

Functional Tests....183

End-to-End Tests....184

Refactoring for Testing....184

Revisiting BulkEventsLambda....185

Refactoring BulkEventsLambda....188

Add Constructors....189

Isolate Side Effects....189

Split Methods....191

Testing BulkEventsLambda....192

Unit Testing....192

Functional Testing....195

End-to-End Testing....200

Local Cloud Testing....205

Cloud Test Environments....208

Summary....210

Exercise....211

7. Logging, Metrics, and Tracing....212

Logging....212

CloudWatch Logs....213

LambdaLogger....214

Java Logging Frameworks....216

Structured Logging....221

Structured Logging in Java....223

CloudWatch Logs Insights....225

Metrics....228

CloudWatch Metrics....228

Lambda Platform Metrics....229

Business Metrics....230

Alarms....232

Distributed Tracing....234

Finding Errors....237

Summary....240

Exercises....241

8. Advanced AWS Lambda....242

Error Handling....242

Classes of Error....242

The Various Behaviors of Lambda Error Processing....243

Deep Dive into Asynchronous Event Source Errors....245

Handling Kinesis and DynamoDB Stream Errors....252

Tracing Errors with X-Ray....253

Error Handling Strategies....253

Scaling....255

Observing Lambda Scaling....255

Scaling Limits and Throttling....257

Thread Safety....259

Vertical Scaling....261

Versions and Aliases, Traffic Shifting....261

Lambda Versions....262

Lambda Aliases....262

Traffic Shifting....263

When (Not) to Use Versions and Aliases....265

Cold Starts....266

What Is a Cold Start?....267

When Does a Cold Start Occur?....267

Identifying Cold Starts....269

Impact of Cold Starts....270

Mitigating Cold Starts....271

Provisioned Concurrency....275

Cold Start Summary....280

State....280

Persistent Application State....281

Caching....283

Lambda and Java Application Frameworks....285

Virtual Private Clouds....288

Architectural Concerns of Using Lambda with a VPCs....289

Configuring Lambda to Use a VPC....290

Alternatives....291

Layers and Runtimes....292

What Are Layers?....292

When to Use, and Not Use, Layers....293

Custom Runtimes....295

Summary....297

Exercises....298

9. Advanced Serverless Architecture....300

Serverless Architecture “Gotchas”....300

At-Least-Once Delivery....300

Impacts of Lambda Scaling on Downstream Systems....304

The “Fine Print” of Lambda Event Sources....311

New Patterns of Architecture Enabled by Serverless Thinking....312

Published Components with the Serverless Application Repository....312

Globally Distributed Applications....314

Summary....323

Exercises....323

10. Conclusion....325

Index....328

Serverless revolutionizes the way organizations build and deploy software. With this hands-on guide, Java engineers will learn how to use their experience in the new world of serverless computing. You’ll discover how this cloud computing execution model can drastically decrease the complexity in developing and operating applications while reducing costs and time to market.

Engineering leaders John Chapin and Mike Roberts guide you through the process of developing these applications using AWS Lambda, Amazon’s event-driven, serverless computing platform. You’ll learn how to prepare the development environment, program Lambda functions, and deploy and operate your serverless software. The chapters include exercises to help you through each aspect of the process.

  • Get an introduction to serverless, functions as a service, and AWS Lambda
  • Learn how to deploy working Lambda functions to the cloud
  • Program Lambda functions and learn how the Lambda platform integrates with other AWS services
  • Build and package Java-based Lambda code and dependencies
  • Create serverless applications by building a serverless API and data pipeline
  • Test your serverless applications using automated techniques
  • Apply advanced techniques to build production-ready applications
  • Understand both the gotchas and new opportunities of serverless architecture

Похожее:

Список отзывов:

Нет отзывов к книге.