serverlessconf tokyo キーノート
TRANSCRIPT
© 2016 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Olivier Klein , AWS Solutions Architect, Asia-Pacific October 2016 ServerlessConf, Tokyo
Go Serverless, Compute Only When it Matters!
The Monolithic Architecture
The Monolithic Architecture - Antipattern
Difficult to scale
Single point of failure
Not fault-tolerant
Difficult to work across teams, often slow to iterate on new functionalities
The Microservices Architecture
Microservices advocate creating a system from a collection of small, isolated services,
each of which owns their data, scalable and resilient to failure
Dr. Werner Vogels CTO - Amazon
No server is easier to manage…
…than no server.
No server is easier to manage…
AWS Lambda
No server is easier to manage…
…than no server.
The Microservices Architecture
Serverless Microservices
Architect to be Serverless Serverless
Fully Managed
• No provisioning
• Zero Administration (
• High-Availability
Developer Productivity
• Focus on the code
• Innovate rapidly
• Reduce time to market
Scalability
• Automatically
• Scale up and down Up/Down
Many Serverless Options on AWS Serverless
Storage Database Network
Compute Content Delivery Messaging and Queues Security
Gateways
User Management Monitoring & Logging
Internet of Things
Machine Learning
Streaming Analytics
13 Regions
35 Availability Zones
63 Edge Locations
Continuous Expansion
AWS Global Infrastructure AWS
(As of September, 2016)
13 Regions
35 Availability Zones
63 Edge Locations
Continuous Expansion
AWS Global Infrastructure AWS
New!
New!
(As of September, 2016)
AWS Lambda
Run your code in the cloud, fully managed and highly-available Triggered through API calls or state changes in your setup (S3, DynamoDB, SNS, Kinesis)
Scales automatically to match the incoming event rate
Charged per 100ms execution time
Amazon Kinesis
Amazon Lambda
Amazon S3
Amazon DynamoDB
Amazon API Gateway
Amazon SNS
Amazon S3 Amazon DynamoDB
Amazon Kinesis
AWS CloudFormation
AWS CloudTrail Amazon CloudWatch
Amazon SNS AmazonSES
AmazonAPI Gateway
Amazon Cognito
AWSIoT
AmazonAlexa
Cron events
DATA STORES ENDPOINTS
REPOSITORIES EVENT/MESSAGE SERVICES
Event Sources that integrate with AWS Lambda (AWS Lambda )
… and the list continues to grow.
Amazon Config
How to build application backends?
Back-end logic Database Mobile
How to build serverless microservices? Serverless Microservices
AWS Lambda
Amazon API Gateway
Amazon DynamoDB
Microservice
How to build serverless microservices? Serverless Microservices
AWS Lambda
Amazon API Gateway
Amazon DynamoDB
Microservice 1
Microservice 2
Microservice N
...
Amazon API Gateway
Fully managed and scalable RESTful API gateway service
Powered by our content delivery network via 63 global edge locations Provides DDoS protection and throttling capabilities Multiple API stages which you define (e.g. dev, test, prod)
AWS Lambda
Amazon API Gateway
Amazon EC2
AWS API
On-prem server
Amazon API Gateway: Authorization
Amazon API Gateway
Allows unauthenticated requests, or authorizes via AWS IAM Amazon Cognito or AWS STS for temporary credential generation API Keys available to monitor individual app calls You can create API Key specific throttling and usage plans
Basic – 5 TPS
Premium – 100 TPS
Power – No throttling
API Keys – Usage Plans
Amazon Cognito
AWS IAM
Webhooks – Integrate with other platforms
Facebook Page AWS Lambda
Slack Channel
Amazon API Gateway
Amazon DynamoDB
Incoming Webhook
Oli just posted on your page!
Oli | 2016-10-01 |
Hello
Okasan Online Securities (岡三オンライン証券株式会社)
“AWS のクラウドネイティブアーキテクチャーにより運用面での作業はほとんど必要なくなり、コストも従来型のアーキテクチャーと比較して、7 分の 1 程度にまで削減することができています。 今のところセキュリティ、実績、コスト、機能の面で AWS に勝るクラウドベンダーはありません。 ”
野崎 保 氏事業戦略担当部長
Online Trading Demo Platform
Live Stock Market Feed and Order Management delivered via Amazon API Gateway and AWS Lambda
1/7 of cost reduction
How to get the web app to the browser? Web
?
Storage and Delivery of the App
Amazon S3
Amazon CloudFront
Amazon S3 • Highly available object storage • Designed for 99.999999999% durability • Offers HTTP / HTTPS endpoint to objects
Amazon CloudFront • Content Delivery Network with 63 edge
locations across the world • Caches content on edge locations for low
latency
Amazon S3 Amazon
CloudFront Browser
Serverless App Architecture
JavaScript SDK
Browser
Amazon S3
Amazon CloudFront
Amazon Lambda
Amazon DynamoDB
Amazon API Gateway
Any other AWS Services (e.g. SNS,
SES, ElastiCache etc.)
Introducing Chalice Chalice Serverless micro-framework for AWS Deploy APIs quickly via AWS Lambda and Amazon API Gateway
github.com/awslabs/chalice
$ chalice new-project helloworld$ cat helloworld/app.py
from chalice import Chalice
app = Chalice(app_name="helloworld")
@app.route("/")def index(): return {"hello": "world"}
$ chalice deploy...Your app is available at: https://endpoint/dev
$ curl https://endpoint/dev{"hello": "world"}
Serverless with AWS
Amazon Lambda
Amazon API Gateway
Amazon S3 Amazon CloudFront
Browser
MOBILE CHAT APP
AD DATA ANALYTICS AND ROUTING
MOBILE APP ANALYTICS
IMAGE CONTENT FILTERING
REAL-TIME VIDEO AD BIDDING
NEWS CONTENT PROCESSING
GENE SEQUENCE SEARCH
CLOUD TELEPHONY
DATA PROCESSING
WEB APPLICATIONS
WEB APPLICATIONS THREAT INTELLIGENCE AND ANALYTICS
NEWS CONTENT PROCESSING
GAME METRICS ANALYTICS
Serverless Applications
How about deployments?
Versioning
Immutable versions of functions Per version configuration
Per version Cloudwatch metrics
Cloudwatch Logs contain version attribute
Aliases to “label” a version release
$LATEST contains latest code
$LATEST(95) STABLE TESTING
94 X
93 X
92
Update Alias to Deploy
$LATEST(95) STABLE TESTING
94 X X
93
92
Update Alias to Deploy
API Stages API
API Gateway Stage Variables API Gateway
API Gateway Stage Variables API Gateway
API Gateway Lambda Custom Domain
/prod/Resources FunctionName:stable https://api.example.com
/dev/Resources FunctionName:$LATEST https://dev.example.com
/qa/Resources FunctionName:qa https://qa.example.com
Pin your environment with stage variables
Alexa, Hello!
The Power of Speech: Alexa
Alexa, the voice service that powers Echo, provides capabilities, or skills, that enable customers to interact with devices using voice
Alexa Skills Kit (ASK) allows everyone to build and publish their own skills
Skills can be powered by AWS Lambda
The Power of Speech: Alexa
Node.js SDK available to quickly build new voice skills. github.com/amzn/alexa-skills-kit-js
var AlexaSkill = require('./AlexaSkill'); var HelloWorld= function () { AlexaSkill.call(this, APP_ID); }; // Extend AlexaSkill HelloWorld.prototype = Object.create(AlexaSkill.prototype); HelloWorld.prototype.constructor = HelloWorld; HelloWorld.prototype.eventHandlers.onLaunch = function (launchRequest, session, response) {
var speechOutput = ”Hello World”; response.tell(speechOutput);
};
Build your own Alexa Skill!
Amazon Echo
Alexa Skills Kit
AWS Lambda Amazon DynamoDB
(Facebook Page
Post)
Final Thoughts
Use Amazon API Gateway to build a front-door to all your microservices (AWS Lambda, Docker, EC2 etc.)
Use microservices with polyglot persistence to avoid bottlenecks, schema issues, quick iterations and allow independent scalability (and caching)
Create many version and stages – no additional charges for APIs, allows for backwards compatibility Use serverless interfaces when possible – HTML5 and JS frameworks like React or Angular are useful
© 2016 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Olivier Klein , AWS Solutions Architect, Asia-Pacific October 2016 ServerlessConf, Tokyo
Thank You!