Upload
others
View
11
Download
0
Embed Size (px)
Citation preview
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Monica Lora
Solutions Architect, AWS
Nils Rhode
Tech Lead & Team Lead, Haufe.Group
Serverless Architectural Patterns
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Agenda• Serverless Foundations • Serverless Architectural patterns:
• Web Application• Data Lake• Stream Processing• Automation
• Serverless at Haufe.Group
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Serverless Means …
No servers to provision or manage
Scales with usage
Never pay for idle Built-in availability and fault tolerance
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SERVICES (ANYTHING)
Changes in data state
Requests to endpoints
Changes in resource state
EVENT SOURCE FUNCTION
Node.jsPythonJavaC#Go
Serverless applications
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon S3 Amazon DynamoDB
Amazon Kinesis
AWS CloudFormation
AWS CloudTrail Amazon CloudWatch
Amazon Cognito
Amazon SNSAmazonSES
Cron events
DATA STORES ENDPOINTS
DEVELOPMENT AND MANAGEMENT TOOLS EVENT/MESSAGE SERVICES
Event sources that trigger AWS Lambda
and more!
AWS CodeCommit
AmazonAPI Gateway
AmazonAlexa
AWS IoT AWS Step Functions
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Lambda Execution Model
Synchronous (push)
Asynchronous (event)
Stream-based
AmazonAPI Gateway
AWS Lambda function
/order
Amazon SNS
AWS Lambda function
Amazon S3
reqs
Amazon DynamoDB
Amazon Kinesis
changes
AWS Lambda service
function
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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
IT Automation
• Policy engines
• Extending AWS services
• Infrastructure management
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pattern 1: Web App/Microservice/API
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Serverless Web Application
Data stored in Amazon
DynamoDB
Dynamic content in AWS Lambda
Amazon API Gateway
Browser
Amazon CloudFront
Amazon S3
Amazon Cognito
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Serverless Web Application - Security
Amazon API Gateway AWS
LambdaAmazon
DynamoDB
AmazonS3
Amazon CloudFront
• Bucket Policies• ACLs
• OAI• Geo-Restriction• Signed Cookies• Signed URLs• DDoS Protection
IAM
AuthZ
IAM
• Throttling• Caching• Usage Plans• ACM
Static Content
Browser
Amazon Cognito
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Serverless Web Application - Security
Amazon API Gateway AWS
LambdaAmazon
DynamoDB
AmazonS3
Amazon CloudFront
• Bucket Policies• ACLs
• OAI• Geo-Restriction• Signed Cookies• Signed URLs• DDOS
IAMAuthZ IAM
• Throttling• Caching• Usage Plans
Static Content
Browser
Amazon CloudFront• HTTPS• Disable Host
Header Forwarding
AWS WAF
Amazon Cognito
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Serverless Web Application - Monitoring
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/
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
Static Content
BrowserCustom CloudWatch
Metrics & Alarms
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Serverless web app lifecycle managementAWS 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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Bustle is a news, entertainment, lifestyle, and fashion website targeted towards women.
With AWS Lambda, we eliminate the need to worry
about operations
Tyler LoveCTO, Bustle
”
“ • Bustle had trouble scaling and maintaining high availability for its website without heavy management
• Moved to serverless architecture using AWS Lambda and Amazon API Gateway
• Experienced approximately 84% in cost savings
• Engineers are now focused on innovation
Bust le Achieves 84% Cost Sav ings with AWS Lambda
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pattern 2: Data Lake
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Characteristics
• Collect/Store/Process/Consume and Analyze all organizational data
• Structured/Semi-Structured/Unstructured data• AI/ML and BI/Analytical use cases• Fast automated ingestion• Schema on Read• Complementary to EDW• Decoupled Compute and Storage
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Serverless Data Lake
S3 Bucket(s)
Key Management
Service
Amazon Athena
AWSCloudTrail
AmazonCognito
AWS IAM
Amazon Kinesis
Streams
Amazon Kinesis
Firehose
Amazon ES
Amazon QuickSight
AWS GlueAmazon
DynamoDB
Amazon Macie
Amazon API Gateway
AWS IAM
Amazon Redshift
SpectrumAWS Direct Connect
Ingest
Catalog & Search
Security & Auditing
API/UI
Analytics & Processing
AWS GlueAWSLambda
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Fannie Mae Serverless Financial Modeling
Financial Modeling is a Monte-Carlo simulation process to project future cash flows , which is used for managing the mortgage risk on daily basis:
• Underwriting and valuation• Risk management • Financial reporting• Loss mitigation and loan removal
• ~10 Quadrillion (10#10$%) of cash flowprojections each month in hundreds of economic scenarios.
• One simulation run of ~ 20 million mortgages takes 1.4 hours, >4 times faster than the existing process.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pattern 3: Stream Processing
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
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
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Streaming data ingestion
Amazon CloudWatch:Delivery metrics
Amazon S3:Buffered files
Kinesis Agent
Record Producers Amazon Redshift:
Table loads
Amazon Elasticsearch Service:Domain loads
Amazon S3:Source record backup
AWS Lambda:Transformations &
enrichment
Amazon DynamoDB:Lookup tables
Raw records
Lookup
Transformed records
Transformed recordsRaw records
Amazon Kinesis Firehose:Delivery stream
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Sensor data collection
IoTrules
IoTactions
MQTT
Amazon S3:Raw records
Amazon Kinesis Firehose:Delivery stream
Amazon S3:Batched records
Amazon Kinesis Streams:Real-time stream
AWS IoT:Data collection
IoT Sensors
Real-time analyticsapplications
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Thomson Reuters – Product Insight
Solution for usage analysis tracking:Capture, analyze, and visualize analytics data generated by offerings, providing insights to help product teams continuously improve the user experience
Throughput: Tested 4,000 requests / secondGrowing to 10,000 requests / second or 25 Billion requests / month
Latency: new events to user dashboards in less than 10 seconds
Durable: no data loss since inception
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pattern 4: Automation
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Automation characteristics
• Periodic jobs • Event triggered workflows• Enforce security policies• Auditing and notification• Respond to alarms• Extend AWS functionality• …All while being Highly Available and Scalable
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Ops Automator Tags
OpsAutomatorTaskList CreateSnapshot
Amazon CloudWatch:Time-based events
AWS Lambda:Event handler
AWS Lambda:Task executors
AWS SNS:Error and warning notifications
Resources in multiple AWS Regions and Accounts
Amazon EC2 Instances
Amazon DynamoDB:Task configuration & tracking
Amazon CloudWatch:Logs
Amazon Redshift Clusters
https://aws.amazon.com/answers/infrastructure-management/ops-automator/
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Serverless @ HAUFE.GROUP
Our True North Goal.
–A family company for the
next generations.
1800employees
13Locations in Germany
5International branches
370 Mio.Sales
All DAX 30
–Companies rely on our expertise
150,000
–Seminar participants at Haufe
Akademie every year
5,500,000
–Users and licences
Our SolutionsPrint
SoftwareTraining
Consulting
MarketsGermany
SwitzerlandUSA
China
1934founded as publishing house
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Our challenge- Re-Engineering the HRS
- from Monolith to Microservices- starting with the first component: EDB (Court Decision Database)
- AIM: • Future-proof by choosing state-of-the-art technics• Low maintenance effort by using services• Fast and cheap way to import millions of documents
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
EDB Architecture on AWS
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Example of our serverless workflows
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
How we realized the mentioned workflow
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Benefits of our work
• Cost-saving (Never pay for idle)10 imports/month with about 1.000 till 10.000 files as fast as possible (scalability)
$79.65
$42.92
$0.46
$4.52
$0.97
16 X T2.NANO 1 X T2.MEDIUM 16 LAMBDAS
Idle Needed~95% paying
for idle
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Benefits of our work
$9,558.00
$5,150.40
$55.20
$55.20
$- $2,000.00 $4,000.00 $6,000.00 $8,000.00 $10,000.00 $12,000.00
t2.nano/each function
t2.medium/all functions
Fee based on imports over all workflows per year
Lambda EC2
Cutting down the cost about
99%
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Benefits of our work
• Easy to extend and maintain• add, change or remove functions (microservice-approach)• Configuration of each step (e.g. failure-handling)• „No server is easier to manage than no server“
• Handy transformation from monolith to microservice
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
How we proceed
- Our bottleneck: RDS database and the limited scaling(costs of Lambda for failover by re-trying: about:10%)
- High costs for ES(only needed for handling queries for export)
=> We‘re waiting for Aurora Serverless
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Summary
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Lambda Best Practices
• Minimize package size to necessities• Separate the Lambda handler from core logic• Use Environment Variables to modify operational behavior• Self-contain dependencies in your function package• Leverage “Max Memory Used” to right-size your functions• Delete large unused functions (75GB limit)
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Summary
Use DevOps tools to automate your serverless deployments
Apply serverless patterns for common use-cases:•Web application• Data Lake Foundation• Stream processing•Operations automation
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Please complete the session survey in theSummit mobile app
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Thank you!What will you build with Serverless?