serverless architectural patterns and best practices
TRANSCRIPT
![Page 1: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/1.jpg)
Serverless Architectural Patterns and Best Practices
Danilo Poccia, Technical Evangelist@danilop
![Page 2: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/2.jpg)
Agenda
Serverless characteristics and practices3-tier web applicationBatch processingStream processingOperations automationServerless on the edgeWrap-up/Q&A
![Page 3: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/3.jpg)
Spectrum of AWS offerings
AWSLambda
Amazon Kinesis
AmazonS3
Amazon API Gateway
AmazonSQS
AmazonDynamoDB
AWS IoT
Amazon EMR
Amazon ElastiCache
AmazonRDS
Amazon Redshift
Amazon Elasticsearch
Service
Managed Serverless
Amazon EC2
“On EC2”
Amazon Cognito
Amazon CloudWatch
![Page 4: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/4.jpg)
Serverless patterns built with functions
Functions are the unit of deployment and scaleScales per request—users cannot over or under-provisionNever pay for idleSkip the boring parts; skip the hard parts
![Page 5: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/5.jpg)
Lambda considerations and best practices
AWS Lambda is stateless—architect accordingly• Assume no affinity with underlying compute
infrastructure• Local filesystem access and child process may not
extend beyond the lifetime of the Lambda request
![Page 6: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/6.jpg)
Lambda considerations and best practicesCan your Lambda functions survive the cold?
• Instantiate AWS clients and database clients outside the scope of the handler to take advantage of connection re-use.
• Schedule with CloudWatchEvents for warmth
• ENIs for VPC support are attached during cold start
import sys import logging import rds_configimport pymysql
rds_host = "rds-instance" db_name = rds_config.db_nametry:
conn = pymysql.connect( except:
logger.error("ERROR:def handler(event, context):
with conn.cursor() as cur:Executes with
each invocation
Executes during cold start
![Page 7: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/7.jpg)
Lambda considerations and best practices
How about a file system?• Don’t forget about /tmp (512 MB
scratch space) exports.ffmpeg = function(event,context) { new ffmpeg('./thumb.MP4', function (err, video) { if (!err) { video.fnExtractFrameToJPG('/tmp’)function (error, files) { … }…if (!error) console.log(files); context.done(); ...
![Page 8: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/8.jpg)
Lambda considerations and best practices
Custom CloudWatch metrics• 40 KB per POST• Default Acct Limit of 150 TPS• Consider aggregating with Kinesis
def put_cstate ( iid, state ): response = cwclient.put_metric_data(
Namespace='AWSx/DirectConnect',MetricData=[{ 'MetricName':'ConnectionState','Dimensions': [
{ 'Name': 'ConnectionId','Value': iid},
],'Value': state,'Unit': 'None’
…
![Page 9: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/9.jpg)
Pattern 1: 3-Tier Web Application
![Page 10: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/10.jpg)
Web application
Data stored in Amazon
DynamoDB
Dynamic content in AWS Lambda
Amazon API Gateway
Browser
Amazon CloudFront
Amazon S3
![Page 11: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/11.jpg)
Amazon API Gateway AWS
LambdaAmazon
DynamoDB
AmazonS3
Amazon CloudFront
• Bucket Policies• ACLs
• OAI• Geo-Restriction• Signed Cookies• Signed URLs• DDOS
IAM
AuthZ
IAM
Serverless web app security
• Throttling• Caching• Usage Plans
Browser
![Page 12: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/12.jpg)
Amazon API Gateway AWS
LambdaAmazon
DynamoDB
AmazonS3
Amazon CloudFront
• Bucket Policies• ACLs
• OAI• Geo-Restriction• Signed Cookies• Signed URLs• DDOS
IAMAuthZ IAM
Serverless web app security
• Throttling• Caching• Usage Plans
Browser
Amazon CloudFront• HTTPS• Disable Host
Header Forwarding
AWS WAF
![Page 13: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/13.jpg)
Amazon API Gateway
AWSLambda
AmazonDynamoDB
AmazonS3
Amazon CloudFront
• Access Logs in S3 Bucket• Access Logs in S3 Bucket
• CloudWatch Metrics-https://aws.amazon.com/cloudfront/reporting/
Serverless web app monitoring
AWS WAF• WebACL Testing• Total Requests• Allowed/Blocked
Requests by ACL
logslogs
• Invocations• Invocation Errors• Duration• Throttled
Invocations
• Latency• Throughput• Throttled Reqs• Returned Bytes• Documentation
• Latency• Count• Cache Hit/Miss• 4XX/5XX Errors
Streams
AWSCloudTrail
BrowserCustom CloudWatch
Metrics & Alarms
![Page 14: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/14.jpg)
Serverless web app lifecycle management
AWS SAM (Serverless Application Model) - blog
AWSLambda
Amazon API Gateway
AWS CloudFormation
AmazonS3
AmazonDynamoDB
Package & Deploy
Code/Packages/Swagger
Serverless Template
Serverless Template
w/ CodeUri
package deployCI/CD Tools
![Page 15: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/15.jpg)
AWS SAM Local
A CLI tool for local development and testing of Serverless applications
https://github.com/awslabs/aws-sam-local
![Page 16: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/16.jpg)
AWS CodeStar
Quickly develop, build, and deploy applicationsNew: GitHub integration
![Page 17: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/17.jpg)
Amazon API Gateway best practices
Use mock integrationsSigned URL from API Gateway for large or binary file uploads to S3Use request/response mapping templates for legacy apps and HTTP response codesAsynchronous calls for Lambda > 30s
![Page 18: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/18.jpg)
Roo
t /
/{proxy+} ANY Your Node.jsExpress app
Greedy variable, ANY method, proxy integration
Simple yet very powerful:
• Automatically scale to meet demand
• Only pay for the requests you receive
![Page 19: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/19.jpg)
Pattern 2: Batch Processing
![Page 20: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/20.jpg)
Characteristics
Large data setsPeriodic or scheduled tasksExtract Transform Load (ETL) jobsUsually non-interactive and long runningMany problems fit MapReduce programming model
![Page 21: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/21.jpg)
Serverless batch processing
AWS Lambda: Splitter
Amazon S3Object
Amazon DynamoDB: Mapper Results
AWS Lambda: Mappers
….
…. AWS Lambda: Reducer
Amazon S3Results
![Page 22: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/22.jpg)
Considerations and best practices
Cascade mapper functionsLambda languages vs. SQLSpeed is directly proportional to the concurrent Lambda function limitUse DynamoDB/ElastiCache/S3 for intermediate state of mapper functionsLambda MapReduce Reference Architecture
![Page 23: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/23.jpg)
Cost of serverless batch processing
200 GB normalized Google Ngram data-set Serverless:
• 1000 concurrent Lambda invocations• Processing time: 9 minutes• Cost: $7.06
![Page 24: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/24.jpg)
Pattern 3: Stream Processing
![Page 25: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/25.jpg)
Stream processing characteristics
• High ingest rate• Near real-time processing (low latency from ingest to
process)• Spiky traffic (lots of devices with intermittent network
connections)• Message durability• Message ordering
![Page 26: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/26.jpg)
Serverless stream processing architecture
Sensors
Amazon Kinesis:Stream
Lambda: Stream Processor
S3:Final Aggregated Output
Lambda:Periodic Dump to S3
CloudWatch Events:Trigger every 5 minutes
S3:Intermediate Aggregated
Data
Lambda:Scheduled Dispatcher
KPL:Producer
![Page 27: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/27.jpg)
Fan-out pattern
• Number of Amazon Kinesis Streams shards corresponds to concurrent Lambda invocations
• Trade higher throughput & lower latency vs. strict message ordering
Sensors
Amazon Kinesis:Stream
Lambda: Dispatcher
KPL:Producer Lambda:
Processors
Increase throughput, reduce processing latency
![Page 28: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/28.jpg)
More about fan-out pattern
• Keep up with peak shard capacity• 1000 records / second, OR• 1 MB / second
• Consider parallel synchronous Lambda invocations• Rcoil for JS (https://github.com/sapessi/rcoil) can help• Dead letter queue to retry failed Lambda invocations
![Page 29: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/29.jpg)
Best practices
• Tune batch size when Lambda is triggered by Amazon Kinesis Streams – reduce number of Lambda invocations
• Tune memory setting for your Lambda function – shorten execution time
• Use KPL to batch messages and saturate Amazon Kinesis Stream capacity
![Page 30: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/30.jpg)
Monitoring
Amazon Kinesis Stream metric GetRecords.IteratorAgeMilliseconds maximum
![Page 31: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/31.jpg)
Amazon Kinesis Analytics
Sensors
Amazon Kinesis:Stream
Amazon Kinesis Analytics: Window Aggregation
Amazon Kinesis StreamsProducer S3:
Aggregated Output
CREATE OR REPLACE PUMP "STREAM_PUMP" AS INSERT INTO "DESTINATION_SQL_STREAM"
SELECT STREAM "device_id",
FLOOR("SOURCE_SQL_STREAM_001".ROWTIME TO MINUTE) as "round_ts",
SUM("measurement") as "sample_sum",
COUNT(*) AS "sample_count"
FROM "SOURCE_SQL_STREAM_001"
GROUP BY "device_id", FLOOR("SOURCE_SQL_STREAM_001".ROWTIME TO MINUTE);
Aggregation Time Window
![Page 32: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/32.jpg)
Cost comparison - assumptions
• Variable message rate over 6 hours• Costs extrapolated over 30 days
20,000
10,000
20,000
50,000
20,000
10,000
1 2 3 4 5 6
MESSAGE
S/SEC
HOURS
![Page 33: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/33.jpg)
Serverless• Amazon Kinesis Stream with 5
shards
Cost comparison
Server-based on EC2• Kafka cluster (3 x m3.large)• Zookeeper cluster (3 x m3.large)• Consumer (1 x c4.xlarge)
Service Monthly Cost
Amazon Kinesis Streams $ 58.04
AWS Lambda $259.85
Amazon S3 (Intermediate Files) $ 84.40
Amazon CloudWatch $ 4.72
Total $407.01
Service Monthly Cost
EC2 Kafka Cluster $292.08
EC2 Zookeeper Cluster $292.08
EC2 Consumer $152.99
Total On-Demand $737.15
1-year All Upfront RI $452.42
![Page 34: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/34.jpg)
Compare related servicesAmazon Kinesis Streams Amazon SQS Amazon SNS
Message Durability Up to retention period Up to retention period Retry delivery (depends on destination type)
Maximum Retention Period 7 days 14 days Up to retry delivery limit
Message Ordering Strict within shard Standard - Best effort FIFO – Strict within Message Group
None
Delivery semantics Multiple consumers pershard
Multiple readers per queue (but one message is only handled by one reader at a time)
Multiple subscribers per topic
Scaling By throughput using Shards Automatic Automatic
Iterate over messages Shard iterators No No
Delivery Destination Types Kinesis Consumers SQS Readers HTTP/S, Mobile Push, SMS, Email, SQS, Lambda
![Page 35: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/35.jpg)
Lambda architecture
Data Sources
Serving Layer
Speed Layer
AWS Lambda: Splitter
Amazon S3Object
Amazon DynamoDB: Mapper Results
AmazonS3
AWS Lambda: Mappers
….
…. AWS Lambda: Reducer
Amazon S3Results
Batch Layer
Sensors
Amazon Kinesis:Stream
Lambda: Stream Processor
S3:Final Aggregated Output
Lambda:Periodic Dump to S3
CloudWatch Events:Trigger every 5 minutes
S3:Intermediate Aggregated
Data
Lambda:Scheduled Dispatcher
KPL:Producer
![Page 36: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/36.jpg)
Pattern 4: Automation
![Page 37: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/37.jpg)
Automation characteristics
• Respond to alarms or events• Periodic jobs • Auditing and Notification• Extend AWS functionality…All while being Highly Available and Scalable
![Page 38: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/38.jpg)
Automation: dynamic DNS for EC2 instancesAWS Lambda:
Update Route53Amazon CloudWatch Events:
Rule TriggeredAmazon EC2 Instance
State Changes
Amazon DynamoDB: EC2 Instance Properties
Amazon Route53: Private Hosted Zone
Tag:CNAME = ‘xyz.example.com’
xyz.example.com A 10.2.0.134
![Page 39: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/39.jpg)
Automation: image thumbnail creation from S3
AWS Lambda: Resize Images
Users upload photos
S3:Source Bucket
S3:Destination Bucket
Triggered on PUTs
![Page 40: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/40.jpg)
CapitalOne Cloud CustodianAWS Lambda:
Policy & Compliance RulesAmazon CloudWatch Events:
Rules Triggered
AWS CloudTrail:Events
Amazon SNS: Alert Notifications
Amazon CloudWatch Logs:Logs
Read more here: http://www.capitalone.io/cloud-custodian/docs/index.html
![Page 41: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/41.jpg)
Serverless by Design
A visual approach to serverless development
Event-driven architectures
https://sbd.danilop.net
https://github.com/danilop/ServerlessByDesign
![Page 42: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/42.jpg)
Serverless by Design
![Page 43: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/43.jpg)
Case Study
• PhotoVogue is an online photography platform. Launched in 2011 and part of Vogue Italia - which is owned by Condé Nast Italia - it allows upcoming photographers to showcase their work.
• Amazon S3, AWS Lambda, Amazon API Gateway, Amazon CloudFront
• The Benefits• Quicker provisioning, from days to hours• 90% faster• Cut IT costs by around 30%• Seamless scalability
https://aws.amazon.com/solutions/case-studies/photovogue/
![Page 44: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/44.jpg)
Case Study
• F-Secure IncreasesCustomer Insight andSpeeds Up ActivationUsing AWS
https://aws.amazon.com/solutions/case-studies/f-secure/
![Page 45: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/45.jpg)
Case Study
• UK Driver and Vehicle Licensing Agency Supports Secure, Data-Driven Innovation
• An API-First Approach• “We are decomposing our applications into smaller, discrete components so
we can choose the most appropriate technology”• Amazon API Gateway
• “The speed with which we were able to deliver it was unprecedented”• Experimenting with AWS Lambda
https://aws.amazon.com/solutions/case-studies/driver-and-vehicle-licensing-agency/
![Page 46: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/46.jpg)
Serverless on the edge
![Page 47: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/47.jpg)
Client Back End
AWSLambda
![Page 48: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/48.jpg)
CDNClient Back End Devices
Sensors
Actuators
AWSLambda
Gateway
![Page 49: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/49.jpg)
AWS Greengrass
![Page 50: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/50.jpg)
Lambda Functions on a Raspberry Pi
AWSGreengrass
LambdaFunction
![Page 51: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/51.jpg)
AWS Snowball Edge100TB + Greengrass Core (≃ EC2 m4.4xlarge instance)
![Page 52: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/52.jpg)
Snowball Edge Use Cases
“Snowball Edge enables us to extend the innovative capabilities of HealthSuite, our cloud-enabled connected health ecosystem of devices, applications and digital tools supported by AWS, even when there is no network support.”
Embedded Applications
—Dale Wiggins,Business Leader, HealthSuite digital platform,
Philips
![Page 53: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/53.jpg)
Snowball Edge Use Cases
“With AWS Snowball Edge, we can now collect 100 TB of data with no intermediate steps, and we can also analyze the images immediately using the onboard compute capabilities.”
Remote Locations for data collection and analysis
— Bob Cowen,Director of Hatfield Marine Research Center,
Oregon State University
![Page 54: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/54.jpg)
AWS Lambda@Edge
Customize content delivery while reducing load on the origin
Events / Triggers
Take serverless to your users
![Page 55: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/55.jpg)
Lambda@Edge Use Cases
Demo build of aCloudFront+S3 distribution,
using Lambda@Edgeto secure its HTTP headers
![Page 56: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/56.jpg)
Lambda@Edge Use Cases
These processes include applying transactional labels to purchases so
Blockbuster can track customer activity, and providing personalized recommendations
based on previous purchases.
Blockbuster runs serverless compute processes across AWS Regions and
Amazon CloudFront edge locations (using Lambda@Edge) without provisioning or
managing servers.
![Page 57: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/57.jpg)
“Serverless” Compliance
• ISO 9001 / 27001 / 27017 / 27018• AWS Lambda• Amazon API Gateway (excluding the use of Amazon API Gateway caching)
• PCI• AWS Lambda• Amazon API Gateway
• HIPAA BAA• AWS Lambda• Amazon API Gateway (excluding the use of Amazon API Gateway caching)
![Page 58: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/58.jpg)
Best practices
• Document how to disable event triggers for your automation when troubleshooting
• Gracefully handle API throttling by retrying with an exponential back-off algorithm (AWS SDKs do this for you)
• Publish custom metrics from your Lambda function that are meaningful for operations (e.g. number of EBS volumes snapshotted)
![Page 59: Serverless Architectural Patterns and Best Practices](https://reader031.vdocuments.mx/reader031/viewer/2022031518/5a6478d87f8b9a2c568b4681/html5/thumbnails/59.jpg)
Thank you!
@danilop