Leo Zhadanovsky from Amazon Web Services gave a presentation on building serverless web applications. He discussed AWS Lambda concepts like no servers to manage and pay per usage model. He also covered API Gateway for unifying APIs, Lambda environment variables, and common use cases like web apps and data processing. Design patterns like moving from a monolithic to microservices architecture were explained. The AWS Serverless Application Model (SAM) and frameworks like Chalice and ClaudiaJS were presented as tools for defining and deploying serverless applications.
2. About Me
Who: Leo Zhadanovsky / @leozh / leozh@amazon.com
What: Principal Solutions Architect
Previous:
Director of Systems Engineering @ DNC / Obama for America 2012
3. What to expect from the session
• Concepts
• Design patterns
• Tooling
• Demo
5. Benefits of Lambda
No servers to provision
or manage
Scales with usage
Never pay for idle Availability and fault
tolerance built in
6. Never pay for Idle
EVENT DRIVEN CONTINUOUS SCALING PAY BY USAGE
7. Function versioning and aliases
• Versions = immutable copies of
code + configuration
• Aliases = mutable pointers to
versions
• Each version/alias gets its own
ARN
• Enables rollbacks, staged
promotions, “locked” behavior for
client
Lambda Function
Version $LATEST
Lambda Function
Version 123
Lambda Function
DEV Alias
Lambda Function
BETA Alias
Lambda Function
PROD Alias
8. Lambda Environment Variables
• Key-value pairs
• Available via standard environment variable
access, such as process.env, or os.environ
• Can optionally be encrypted via AWS KMS
9. Common Lambda Use Cases
Web
Applications
• Static websites
• Complex web
apps
• Packages for
Flask and
Express
Data
Processing
• Real time
• MapReduce
• Batch
Chatbots
• Powering
chatbot logic
Backends
• Apps &
services
• Mobile
• IoT
</></>
Amazon
Alexa
• Powering
voice-enabled
apps
• Alexa Skills
Kit
Autonomous
IT
• Policy engines
• Extending
AWS services
• Infrastructure
management
11. Unify multiple microservices
under single API front-end
Authenticate and
Authorize Requests
Throttling and DDoS Protection
Amazon API Gateway
12. Amazon EC2 Instances
Lambda Functions
Other AWS Services
API Gateway
On Premise Servers
/v1/user /v1/user/image
Unified API
13. SIGv4 Lambda Custom Auth
{ }
API Keys
• Invoke with Caller Credentials
• AWS Identity and Access
Management (IAM) Roles
• Amazon Cognito
• Per Method Authorization
• OAuth
• On Premise Authentication
• Custom built auth
• Usage Plans
• Quotas per API Key
• Throttling per API Key
• Per Method Authorization
Auth
14. Throttling / DDoS / Scaling
DDoS Protection
• Layer 7 and Layer 3 Protection
• Cloudfront in front of API Gateway
Throttling
• Usage Plans
• Quotas per API Key
• Throttling per API Key
Scaling
• Auto Scaling
• Caching Layer
15. API Gateway Stage Variables
• Stage variables act like environment variables
• Use stage variables to store configuration values
• Stage variables are available in the $context object
• Values are accessible from most fields in API Gateway
• Lambda Function ARN
• HTTP endpoint
• Custom authorizer function name
• Parameter mappings
21. Monolithic - What does it look like?
GET /pets
PUT /pets
DELETE /pets
GET /describe/pet/$id
PUT /describe/pet/$id
EVENT DRIVEN ONE LARGE LAMBDA FUNCTION
22. Monolithic - Pros and Cons
• Single Handler
• Handles all GET/PUT/POST/UPDATE/DELETE
• Very Large Lambda Function
• Have to build a routing mechanism
• Larger blast radius
Cons:
Pros:
• Sometimes its easier to comprehend a less
distributed system
• Deployments “could” be faster
26. Microservices - What does it look like?
EVENT DRIVEN ONE LAMBDA PER HTTP METHOD
GET /pets
PUT /pets
DELETE /pets
GET /describe/pet/$id
PUT /describe/pet/$id
27. Microservices - Pros and Cons
• Can be harder to debug (X-ray can help with this!)
• Multiple Lambda Functions to Manage (Use SAM!!!!)
Cons:
Pros:
• Easier for teams to work Autonomously
• Separation of components
• Fine grained deployments (Integration testing is important)
• Can be easier to debug
• Agile
28. What does it look like put together?
Amazon
S3
Amazon
API Gateway
S3 stores all of your static
content: CSS, JS, Images, etc.
API Gateway handles all of
your application routing.
Lambda runs all of the logic
behind your website. Such as
a Create/Read/Update/Delete
service.
29. How do I manage it?
MEET SAM
USE SAM TO BUILD TEMPLATES THAT DEFINE
YOUR SERVERLESS APPLICATIONS
DEPLOY YOUR SAM TEMPLATE
WITH AWS CLOUDFORMATION
30. AWS Serverless Application Model (SAM)
AWS CloudFormation extension optimized
for serverless
New serverless resource types: functions,
APIs, and tables
Supports anything CloudFormation supports
Open specification (Apache 2.0)
37. Wrap-Up
Things to remember:
• AWS SAM (Serverless Application Model)
• Helps you define your entire Serverless application
• Lots of frameworks out there to help you get started
quickly
• ClaudiaJS, Zappa, Sparta, Apex, Chalice, aws-
serverless-express, Lambada, Serverless Framework
• If you’re just getting started, Start small!
• If you have questions, don’t be afraid to ask, the
community around Serverless is fantastic!