Leanpub Header

Skip to main content

Serverless

Patterns of Modern Application Design Using Microservices (Amazon Web Services Edition)

"Serverless" application architectures offer tremendous cost savings and colossal horizontal scaling ability, with the side benefit of encouraging loosely coupled design. The advantages are so profound, that the days of monolithic application servers might be numbered. To that aim, this book gives you a deep dive into designing and deploying your own serverless applications.

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
736
Readers
315
Pages
39,992Words
About

About

About the Book

The implications of choosing a serverless architecture are large and varied. Therefore, the content of this book should appeal to a broad range of people interested in architecture, design, development, deployment, testing, and maintenance of systems.

If you’re already a fan of microservices (versus monolith or n-tier) systems, this book will provide you with ammunition to lobby for their increased adoption amongst your peers and coworkers, along with plenty of practical advice and concrete examples to help you figure out what you’re doing.

While my primary recurring example is of a greenfield application that has been designed from the start with this approach, you should find the information herein to also apply to decomposition of existing, monolithic or dysfunctional systems as well. There are also plenty of real-life examples including case studies.

While there are a handful of viable technologies that may be used to achieve a serverless architecture, this book focuses on Amazon Web Services. In my opinion, their revolutionary Lambda product is the world’s first viable attempt to provide infinitely scalable computation-on-demand. In their words, it gives you the ability to run code, not servers.

Guide to Readers

This book has four main parts. I’ve done my best to make sure it will be a delight to read straight through chapter by chapter. At the same time, the book is apportioned into major parts that I hope will make it useful as a reference companion.

The first part entitled The Story encompasses Chapters 1 thru 5 and is an introduction to the main concepts and technology involved in building serverless applications using microservices with Amazon Web Services.

The second part called The Case Study is the story of our case study and source of example code, a tech startup called FoodButton. Throughout the book, we have made an effort to relate the story of our case study in vivid detail, including context for the architectural decisions. We feel that the best way to learn about how to design applications is by understanding the context of the decisions made while building and evolving actual systems.

The third part is The Patterns and it is where we list out the patterns that we find relevant to the building and integrating of microservices. Some of the patterns are quite large in scope, especially the ones pertaining to architectural styles.

The Services provides a high-level reference guide to the AWS products most relevant to serverless microservices design. This part does not go in-depth because we understand more than anyone else that the best place to get that information is online.”

Table of Contents (Jan 4, 2015)

Preface

Who Should Read This Book

Guide to Readers

Acknowledgments

Debt of Gratitude

Open-Source

Colophon

The Story

1. Introduction

1.1 Benefits of the Approach

1.2 Historical Context

1.3 Cost Considerations

1.4 Other Platforms

1.5 Prerequisites

2. Microservices

2.1 Characteristics

2.2 Versus Layered Architecture

2.3 Microservices ala Fred George

2.4 Drawbacks

3. AWS Fundamentals

3.1 AWS Command-Line Interface

3.2 SDK Libraries

3.3 Configuration Information

3.4 Credentials

3.5 Signed Requests

3.6 Retry Logic

3.7 Regions

3.8 Service Limits

4. Serverless Framework

4.1 Summary

4.2 Deployment

4.3 Configuration

4.4 Installing SLS

4.5 Creating a Project

5. Saws

5.1 Installation

5.2 Usage

5.3 DynamoDB

5.4 SNS (Simple Notification Service)

The Case Study

6. FoodButton

6.1 Functionality

6.2 A Living System

6.3 Sample Code

6.4 Systems

6.5 High-Level Requirements

6.6 Collaboration of Microservices

6.7 Implementation Using AWS

7. Waiter

7.1 API Gateway Setup

7.2 Lambda Handler Function

8. StripeCashier

9. FeedbackHistorian

10. RestaurantPicker

11. RestaurantNotifier

12. DataWarehouseClerk

The Patterns

13. Architectural Patterns

13.1 Asynchronous Messaging

13.2 Big Ball of Mud

13.3 Command and Query Responsibility Segregation (CQRS)

13.4 Event-Driven Architecture

13.5 Orchestrated Workflow

13.6 Pipes and Filters

14. Microservice Roles

14.1 Message Originator

14.2 Content Enricher

14.3 Event Mediator

14.4 Event Processor

14.5 Coexistant Versions

14.6 Fanout

14.7 Async Waterfall (with optional Fanout)

14.8 Need Solution

14.9 Transformer

14.10 Worker

15. Integration Styles

15.1 File Transfer

15.2 Shared Database

15.3 Remote Procedure Invocation

15.4 Messaging

16. Messaging Systems

16.1 Message Channel

16.2 Message

16.3 Message Router

16.4 Message Translator

16.5 Message Endpoint

17. Messaging Channels

17.1 Point-to-Point Channel

17.2 Publish-Subscribe Channel

17.3 Datatype Channel

17.4 Invalid Message Channel

17.5 Dead Letter Channel

17.6 Guaranteed Delivery

17.7 Channel Adapter

17.8 Messaging Bridge

17.9 Message Bus

18. Message Construction

18.1 Command Message

18.2 Document Message

18.3 Event Message

18.4 Request-Reply

18.5 Return Address

18.6 Correlation Identifier

18.7 Message Sequence

18.8 Message Expiration

18.9 Format Indicator

19. Message Routing

19.1 Content-Based Router

19.2 Message Filter

19.3 Dynamic Router

19.4 Recipient List

19.5 Splitter

19.6 Aggregator

19.7 Resequencer

19.8 Composed Message Processor

19.9 Scatter-Gather

19.10 Routing Slip

19.11 Process Manager

19.12 Queue Coupling

19.13 Message Broker

20. Message Transformation

20.1 Envelope Wrapper

20.2 Content Enricher

20.3 Content Filter

20.4 Claim Check

20.5 Normalizer

20.6 Canonical Data Model

21. Messaging Endpoints

21.1 Messaging Gateway

21.2 Messaging Mapper

21.3 Transactional Client

21.4 Polling Consumer

21.5 Event-Driven Consumer

21.6 Competing Consumers

21.7 Message Dispatcher

21.8 Selective Consumer

21.9 Durable Subscriber

21.10 Idempotent Receiver

21.11 Service Activator

22. System Management

22.1 Control Bus

22.2 Detour

22.3 Wire Tap

22.4 Message History

22.5 Message Store

22.6 Smart Proxy

22.7 Test Message

22.8 Channel Purger

The Services

23. API Gateway

24. Lambda

25. Identity and Access Management (IAM)

26. DynamoDB

26.1 Concepts

27. Cognito

27.1 Initial Setup

27.2 Using Cognito in Client Code

28. Simple Notification Service (SNS)

28.1 Example Uses

28.2 Benefits

28.3 Basics

29. Simple Queue Service (SQS)

29.1 Architectural Overview

29.2 SQS Features

29.3 Properties of Distributed Queues

29.4 How is Amazon SNS different from Amazon SQS?

30. S3 (Simple Storage Service)

30.1 Buckets

30.2 Static Website Hosting

30.3 Events

30.4 Storage Classes

31. ElastiCache

31.1 Memcached

31.2 Redis

31.3 Features

32. Redshift

33. Simple Workflow (SWF)

34. CloudFront

35. CloudWatch

36. Elastic Beanstalk (EB)

37. Virtual Private Cloud (VPC)

Appendix

Getting Started with AWS

Setup an AWS Account

Create An Administrative IAM User

Store credentials locally

Attach AdministratorAccess policy

Glossary

Index

Bibliography

Share this book

Price

Pick Your Price...

Minimum price

$33.99

$49.99

You pay

$49.99

Author earns

$39.99
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 3)

3
The author will earn $36.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

Obie Fernandez

The "one and only" Obie Fernandez is an avid writer and technology enthusiast, in addition to achieving worldwide success as an electronic music producer and touring DJ. He is a Principal Engineer at Shopify and boasts a legendary 30 year career in software development and entrepreneurship.

Obie has been CTO and co-founder of many startups including Mark Zuckerberg's beloved Andela and Trevor Owen's Lean Startup Machine. His published books include Patterns of Application Development Using AI many editions of The Rails Way and the acclaimed business title The Lean Enterprise. He also founded one of the world's best known Ruby on Rails web design and development agencies, Hashrocket and served for many years as the series editor for Addison-Wesley's Professional Ruby Series.

On the rare occasion when Obie is not busy building products, consulting clients or writing books, you can find him behind the lens of his camera or DJing in the dust at Burning Man.

Follow @obie on Twitter or email him at obiefernandez@gmail.com 

Leanpub Podcast

Episode 24

An Interview with Obie Fernandez

Contents

Table of Contents

Preface

  1. Who Should Read This Book
  2. Guide to Readers
  3. On Being Opinionated
  4. Acknowledgments
  5. Colophon
  6. IThe Story

1.Introduction

  1. 1.1BaaS
  2. 1.2FaaS
  3. 1.3Amazon Web Services
  4. Google Cloud
  5. 1.4Benefits of a Serverless Microservices Approach
  6. 1.5Historical Context
  7. 1.6Cost Considerations
  8. 1.7Prerequisites
  9. 1.8Terminology
  10. 1.9Static Structure
  11. 1.10Motivation and Values

2.Microservices

  1. 2.1Characteristics
  2. 2.2Versus Layered Architecture
  3. 2.3Microservices ala Fred George
  4. 2.4Drawbacks

3.Practical Concerns

  1. 3.1Team & Project Organization
  2. 3.2Developer Sandbox Accounts
  3. 3.3Testing
  4. 3.4Deployment
  5. 3.5Other Architecture Concerns
  6. IIThe Patterns

4.Architectural Patterns

  1. 4.1Asynchronous Messaging
  2. 4.2Command and Query Responsibility Segregation (CQRS)
  3. 4.3Event-Driven Architecture
  4. 4.4Orchestrated Workflow

5.Microservice Roles

  1. 5.1Message Originator
  2. 5.2Content Enricher
  3. 5.3Mediator
  4. 5.4Coexisting Versions
  5. 5.5Fanout
  6. 5.6Async Waterfall (with optional Fanout)
  7. 5.7Need Solution
  8. 5.8Transformer
  9. 5.9Worker

6.Integration Styles

  1. 6.1File Transfer
  2. 6.2Shared Database
  3. 6.3Remote Procedure Invocation
  4. 6.4Messaging

7.Messaging Systems

  1. 7.1Message Channel
  2. 7.2Message
  3. 7.3Message Router
  4. 7.4Message Translator
  5. 7.5Pipes and Filters

8.Messaging Channels

  1. 8.1Point-to-Point Channel
  2. 8.2Publish-Subscribe Channel
  3. 8.3Datatype Channel
  4. 8.4Invalid Message Channel

9.Message Construction

  1. 9.1Command Message
  2. 9.2Document Message
  3. 9.3Event Message
  4. 9.4Request-Reply
  5. 9.5Return Address
  6. 9.6Correlation Identifier
  7. 9.7Message Sequence
  8. 9.8Message Expiration
  9. 9.9Format Indicator

10.Message Routing

  1. 10.1Content-Based Router
  2. 10.2Message Filter
  3. 10.3Dynamic Router
  4. 10.4Recipient List
  5. 10.5Splitter
  6. 10.6Aggregator
  7. 10.7Resequencer
  8. 10.8Composed Message Processor
  9. 10.9Scatter-Gather
  10. 10.10Routing Slip
  11. 10.11Process Manager
  12. 10.12Queue Coupling
  13. 10.13Message Broker

11.Message Transformation

  1. 11.1Envelope Wrapper
  2. 11.2Content Enricher
  3. 11.3Content Filter
  4. 11.4Claim Check
  5. 11.5Normalizer
  6. 11.6Canonical Data Model

12.Messaging Endpoints

  1. 12.1Messaging Gateway
  2. 12.2Competing Consumers
  3. 12.3Message Dispatcher
  4. 12.4Selective Consumer
  5. 12.5Durable Subscriber
  6. 12.6Using SQS
  7. 12.7Using Kinesis
  8. 12.8Idempotent Receiver

13.System Management

  1. 13.1Control Bus
  2. 13.2Message History
  3. IIIThe Services

14.API Gateway

15.Lambda

16.Identity and Access Management (IAM)

17.DynamoDB

  1. 17.1Concepts

18.Cognito

  1. 18.1Initial Setup
  2. 18.2Using Cognito in Client Code

19.Simple Notification Service (SNS)

  1. 19.1Example Uses
  2. 19.2Benefits
  3. 19.3Basics

20.Simple Queue Service (SQS)

  1. 20.1Architectural Overview
  2. 20.2SQS Features
  3. 20.3Properties of Distributed Queues
  4. 20.4How is Amazon SNS different from Amazon SQS?

21.S3 (Simple Storage Service)

  1. 21.1Buckets
  2. 21.2Static Website Hosting
  3. 21.3Events
  4. 21.4Storage Classes

22.ElastiCache

  1. 22.1Memcached
  2. 22.2Redis
  3. 22.3Features

23.Redshift

24.Simple Workflow (SWF)

25.CloudFront

26.CloudWatch

27.Elastic Beanstalk (EB)

28.Virtual Private Cloud (VPC)

  1. IVThe Case Study

29.FoodButton

  1. 29.1Functionality
  2. 29.2A Living System
  3. 29.3Sample Code
  4. 29.4Systems
  5. 29.5High-Level Requirements
  6. 29.6Collaboration of Microservices
  7. 29.7Implementation Using AWS
  8. 29.8Conclusion

30.Waiter

  1. 30.1API Gateway Setup
  2. 30.2Lambda Handler Function

31.StripeCashier

32.FeedbackHistorian

33.RestaurantPicker

34.RestaurantNotifier

35.DataWarehouseClerk

  1. 35.1Implementation

36.DeliveryMap

  1. Appendix

Getting Started with AWS

  1. Setup an AWS Account
  2. Create An Administrative IAM User
  3. Store credentials locally
  4. Attach AdministratorAccess policy

AWS Fundamentals

  1. AWS Command-Line Interface
  2. SDK Libraries
  3. Configuration Information
  4. Credentials
  5. Signed Requests
  6. Retry Logic
  7. Regions
  8. Service Limits

Serverless Framework

  1. Summary
  2. SLS Services
  3. Example
  4. Installing SLS
  5. Creating a Project
  6. Deployment

Saws

  1. Installation
  2. Usage
  3. DynamoDB
  4. SNS (Simple Notification Service)

Glossary

Index

Bibliography

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub