SlideShare a Scribd company logo
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Webinar
https://amzn.to/JPWebinar https://amzn.to/JPArchive
Solutions Architect
2019/04/09
Let’s Dive Deep into AWS
Lambda
[AWS Black Belt Online Seminar]
Part1 & Part2
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
• 2019 4 1
AWS (http://aws.amazon.com)
• AWS
AWS
•
• AWS does not offer binding price quotes. AWS pricing is publicly available and is subject to
change in accordance with the AWS Customer Agreement available at
http://aws.amazon.com/agreement/. Any pricing information included in this document is provided
only as an estimate of usage charges for AWS services based on certain information that you
have provided. Monthly charges will be based on your actual use of AWS services, and may vary
from the estimates provided.
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Who am I ?
Keisuke Nishitani
Manager, Specialist Solutions Architect
Amazon Web Service Japan K.K
@Keisuke69 Keisuke69 Keisuke69 Keisuke69Keisuke69x
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Lambda
AWS Lambda
/
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Photo credit: Ajith (അജിത്ത്) via Visualhunt / CC BY-SA
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Photo credit: Leo Hidalgo (@yompyz) via VisualHunt / CC BY
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
• OS
•
•
•
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Undifferentiated Heavy Lifting
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Photo credit: kizzzbeth via Visual hunt / CC BY
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Developers need …
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
More efficiency
More scalability
More agility
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
And…
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
No more servers
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Lambda
AWS Lambda
/
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
LEVELOFABSTRACTIONComputing
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
•
•
•
•
•
LEVELOFABSTRACTIONComputing
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Virtual Servers
in Datacenters
LEVELOFABSTRACTIONComputing
• HW
•
•
• Elastic
•
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Virtual Servers
in Datacenters
Virtual Servers
in Datacenters
LEVELOFABSTRACTIONComputing
•
•
•
•
•
• ( )
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Virtual Servers
in Datacenters
Virtual Servers
in Datacenters
Serverless
•
•
•
•
•
AWS Lambda
AWS Fargate
LEVELOFABSTRACTIONComputing
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
/ /
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Compute
スケールの単位 インスタンス アプリケーション 関数
抽象化 ハードウェア OS ランタイム
使いドコロ
• OS、ネットワーク、スト
レージのレベルで構成を制御
したい
• 好みのOSを利用したい
• OS以上の全てを自分でコン
トロールしたい
• サーバを自分で構成して実行
したい
• アプリケーションの構成を制
御したい
• スケールを自分でコントロー
ルしたい
• 必要なときだけコードの実行
を行いたい
• インフラの構成・管理を行い
たくない
Amazon EC2 Container Services AWS Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Lambda release history
?
*As of October 2018, does not include region launches
2015 2016 2017 2018
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
API Gateway S3
Amazon Kinesis
Data Streams SQS
S3
DynamoDB
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
SECURITY
DEV TOOLS
MONITORING
EVENT SOURCES DOWN STREAMS
AWS Cloud9
AWS SAM
AWS CodeBuild
AWS CodePipeline
AWS CodeDeploy
AWS CodeCommit
AWS SAM CLI
AWS X-Ray
AWS CodeStar
Amazon S3
Amazon Kinesis
Amazon DynamoDB
Amazon SQS
Amazon API Gateway
AWS CloudWatch AWS CloudWatch Logs AWS Config
AWS IAMAWS WAFAmazon Cognito
Amazon SNS
Amazon SES
AWS IoT
AWS AppSync
Amazon Lex
AWS CloudWatch Events
Amazon S3
Amazon DynamoDB
Any AWS Services
External API
AWS Lambda
AWS Step Functions
AWS Amplify
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
0.0% 10.0% 20.0% 30.0% 40.0% 50.0% 60.0% 70.0% 80.0% 90.0% 100.0%
Google Kubernetes Engine
Google Firebase
Amazon SageMaker
AWS IoT
Amazon Redshift (Spectrum)
Amazon Kinesis Data Firehose
Amazon Fargate
Amazon SQS
Amazon Kinesis Data Streams
AWS Step Functions
Amazon Cognito
Amazon ECS
Amazon Aurora
Amazon DynamoDB
Amazon API Gateway
AWS Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
0.0% 5.0% 10.0% 15.0% 20.0% 25.0% 30.0% 35.0% 40.0% 45.0%
インタラクティブモバイル
0.その他
画像データ加⼯処理
外部向けサービスの認証機能
IoT関連領域
チャットボット、Alexaスキル
企業内データの収集・加⼯処理
業務系API、グループ企業間API
イベント駆動の業務間連携
モバイルバックエンド
ログデータ処理、機械学習ELTデータパイプライン
動的Webシステム
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Lambda
AWS Lambda
/
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
AWS Lambda
•
• 1
•
JSON
• ZIP
• Amazon S3
• S3 ARN
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
2019 4 1
Python 2.7, 3.6, 3.7
Node.js 6.10, 8.10
.NET Core 1.0(C#), 2.0(C#), 2,1(C#/PowerShell 6.0)
Go 1.x
Java 8
Ruby 2.5
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda -
• 64MB 128MB 3008MB
• CPU
•
• Lambda
• 900 15
• AWS IAM
• IAM Lambda AWS
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
TCP/IP UDP/IP
ptrace
TCP 25
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Lambda
: Amazon Linux
AMI: amzn-ami-hvm-2017.03.1.20170812-x86_64-gp2
Linux : 4.14.77-70.59.amzn1.x86_64
AWS SDK for JavaScript: 2.290.0
SDK for Python (Boto 3)
• Python 3.6: boto3-1.7.74 botocore-1.10.74
• Python 3.7: boto3-1.9.42 botocore-1.12.42
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS
• Lambda
3
•
•
• Lambda Lambda
•
• Lambda
•
AWS Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
2019 4 1
Amazon S3
Amazon DynamoDB
Amazon Kinesis Data Streams
Amazon Simple Notification Service
Amazon Simple Email Service
Amazon Simple Queue Service
Amazon Cognito
AWS CloudFormation
Amazon CloudWatch Logs
Amazon CloudWatch
AWS CodeCommit
Schedlued Event(Amazon CloudWatch Events )
AWS Config
Amazon Alexa
Amazon Lex
Amazon API Gateway
AWS IoT
Amazon CloudFront
Amazon Kinesis Data Firehose
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS CLI
• AWS
• InvocationType Event
•
• InvocationType RequestResponse
• Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
•
• FunctionError
• Limit
URL
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/API_Invoke.html#API_Invok
e_Errors
• AWS
•
• 2
•
• Dead Letter Queue DLQ Amazon SQS
Amazon SNS
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
•
•
• Visibility Timeout
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
VPC
Amazon RDS Amazon Elasticache VPC
VPC Lambda VPC
•
• Availbility Zone (AZ) 1
• AZ IP AZ Lambda
Elastic Network Interface(ENI)
• Lambda
• ENI IP DHCP
• IAM Role ”AWSLambdaVPCAccessExecutionRole”
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
VPC
• IP
• NAT Amazon VPC NAT
ENI IP
• CloudWatch Logs
•
ENI
Projected peak concurrent executions * (Memory in GB / 3GB)
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
VPC FAQ
IP
ENI Lambda
IP
VPC
Managed Nat Gateway NAT
IP
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
VPC FAQ
Lambda
Lambda
AWS Direct Connect VPN
Lambda ENI 10 60
ENI Lambda
ENI Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
-
Lambda AWS
• Amazon CloudWatch Logs
• Lambda Lambda
• AWS Identity and Access Management (IAM)
• ”AWS Lambda”
•
Lambda AWS
• Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
-
AWSLambdaBasicExecutionRole
• CloudWatch
AWSLambdaKinesisExecutionRole
• Amazon Kinesis
AWSLambdaDynamoDBExecutionRole
• Amazon DynamoDB
AWSLambdaSQSQueueExecutionRole
• Amazon Simple Queue Service (Amazon SQS)
AWSLambdaVPCAccessExecutionRole
• VPC Elastic Network Interface
AWSXrayWriteOnlyAccess
• X-Ray
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
-
Lambda
•
• AWS
Lambda AWS
• principal AWS ID
IAM
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
1,000
•
(
: 429)
• 15 30
ConcurrentExecutions UnreservedConcurrentExecutions
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
•
•
• Amazon SQS 5
1 60
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
1s 2s 3s 4s 5s
秒間リクエスト:
10 req/sec
関数の平均実行時間: 3s / exec
同時実行数
= “同時”に実行されているタイミング
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
-
同時実行数
ストリーム
シャード1
シャード2
シャード3
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
1 500
• 1000
•
10,000
10,000
• ” ”
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
1. ENI
2.
3.
4.
5.
6. /
7.
• VPC
• 10 30
• Duration
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
1. ENI
2.
3.
4.
5.
6. /
7.
•
• S3 ZIP
• Duration
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
1. ENI
2.
3.
4.
5.
6. /
7.
•
•
• Duration
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
1. ENI
2.
3.
4.
5.
6. /
7.
• /
• Duration
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
1. ENI
2.
3.
4.
5.
6. /
7. • Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
1. ENI
2.
3.
4.
5.
6. /
7.
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
1. ENI
2.
3.
4.
5.
6. /
7.
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
1. ENI
2.
3.
4.
5.
6. /
7.
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
1. ENI
2.
3.
4.
5.
6. /
7.
1~6
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
• 1
•
•
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
• 1
•
•
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
freeze
•
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
•
1000
75GB
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
128 MB 3008 MB 64 MB
900 seconds (15 )
4 KB
20 KB
5 layers
( ) 6 MB ( )
256 KB ( )
50 MB (zip )
250 MB ( : )
3 MB ( )
( ) 10
/tmp 512 MB
1024
/ 1024
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
( )
• 100
• $0.20/100
(1 $0.0000002)
( )
• 100ms 100ms
•
) 128MB $ 0.000000208/100ms
• 1GB 1
$0.00001667
• http://qiita.com/Keisuke69/items/e3f79b50b6039175401b
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Lambda
AWS Lambda
/
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
•
• Lambda
• JSON
•
• 2
•
• true
• false callback
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
• Lambda
• AWS CloudWatch Logs
•
• CloudWatch Logs
•
• Lambda
•
• Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
•
Amazon S3 Amazon DynamoDB
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
• Python Node.js
Lambda
Lambda
•
Serverless Application Repository
•
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
•
•
•
•
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
Node.js
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/programming-model.html
Python
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/python-programming-model.html
Java
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/java-programming-model.html
Go
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/go-programming-model.html
C#
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/dotnet-programming-model.html
PowerShell
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/powershell-programming-model.html
Ruby
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/lambda-ruby.html
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Cloud9
•
Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
.zip .jar
• zip
•
) Node.js node_modules
zip
•
https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/deployment-package-v2.html
Lambda
•
$ zipinfo test.zip
Archive: test.zip
Zip file size: 473 bytes, number of entries: 2
-r--r--r-- 3.0 unx 0 bx stor 17-Aug-10 09:37 exlib.py
-r--r--r-- 3.0 unx 234 tx defN 17-Aug-10 09:37 index.py
2 files, 234 bytes uncompressed, 163 bytes compressed: 30.3%
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
1000
• A 100
• B 200
• 700(1000-100-200=700)
DB API
ENI/IP
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
•
• DB URL 2 Lambda
•
• Node.js process.env
Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Key Management Service AWS KMS
• Lambda KMS
•
•
• Lambda
•
•
• AWS KMS
• kms:Decrypt
•
• Lambda
• Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
_HANDLER
AWS_REGION Lambda AWS
AWS_EXECUTION_ENV AWS_Lambda_
AWS_Lambda_java8
AWS_LAMBDA_FUNCTION_NAME
AWS_LAMBDA_FUNCTION_MEMORY_SIZE (MB )
AWS_LAMBDA_FUNCTION_VERSION
AWS_LAMBDA_LOG_GROUP_NAME
AWS_LAMBDA_LOG_STREAM_NAME
Amazon CloudWatch Logs
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_SESSION_TOKEN
LANG en_US.UTF-8
TZ (UTC) NTP
LAMBDA_TASK_ROOT Lambda
LAMBDA_RUNTIME_DIR
PATH /usr/local/bin:/usr/bin/:/bin:/opt/bin
LD_LIBRARY_PATH /lib64:/usr/lib64:$LAMBDA_RUNTIME_DIR:$LAMBDA_RUNTIME_DIR/lib:$LAMBDA_TASK_
ROOT:$LAMBDA_TASK_ROOT/lib:/opt/lib
NODE_PATH (Node.js) /opt/nodejs/node8/node_modules/:/opt/nodejs/node_modules:$LAMBDA_RUN
TIME_DIR/node_modules
PYTHONPATH (Python) $LAMBDA_RUNTIME_DIR.
GEM_PATH (Ruby) $LAMBDA_TASK_ROOT/vendor/bundle/ruby/2.5.0:/opt/ruby/gems/2.5.0.
AWS_LAMBDA_RUNTIME_API ( ) API
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
4KB
• [a-zA-Z]
• ([a-zA-Z0-9_] )
• AWS Lambda
) Lang, LD_LIBRARY_PATH
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
•
ARN
• Lambda / publish
• PublishVersion
• $LATEST
•
•
exports.handler = function(event,context) {context.succeed(“bye”);}
exports.handler = function(event,context) {context.succeed(“hi”);}
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
•
•
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
routing-config 2
%
1. 2
2. 98
3.
4.
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
:
• FunctionName
• FunctionName:$LATEST
• FunctionName:1
• FunctionName:2
:
• FunctionName:production
• FunctionName:v1_2_3_4
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda Layers
Lambda
Lambda Layer
Layer
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda Layers
ZIP
Lambda Layer
Layers immutable
5 Layers
Layer
Lambda
Layers
arn:aws:lambda:region:accountId:layer:shared-lib
Lambda
Layers
arn:aws:lambda:region:accountId:layer:shared-lib:2
Lambda
Layers
arn:aws:lambda:region:accountId:layer:shared-lib:3
20190402 AWS Black Belt Online Seminar Let's Dive Deep into AWS Lambda Part1 & Part2
20190402 AWS Black Belt Online Seminar Let's Dive Deep into AWS Lambda Part1 & Part2
20190402 AWS Black Belt Online Seminar Let's Dive Deep into AWS Lambda Part1 & Part2
20190402 AWS Black Belt Online Seminar Let's Dive Deep into AWS Lambda Part1 & Part2
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda Layers
/opt
•
•
Layer 1 5
• 250MB
• Layer zip or S3
/opt
• Python – python, python/lib/python3.7/site-packages (site directories)
• Node.js –
nodejs/node_modules, nodejs/node8/node_modules (NODE_PATH)
https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
•
Lambda
•
Lambda AWS
AWS
CLI
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
DLQ
2
Amazon SQS Amazon SNS
•
• Amazon SQS: SendMessage
• Amazon SNS: Publish
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
DLQ
DLQ DLQ
DeadLetterErrors
RequestID ID
ErrorCode 3 HTTP
ErrorMessage (1 KB )
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Custom Runtimes
Linux Lambda
Runtime API
AWS C++/Rust OSS
https://github.com/awslabs/aws-lambda-cpp-runtime
https://github.com/awslabs/aws-lambda-rust-runtime
PHP/Erlang/Elixir/COBOL
provided
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Runtime bootstrap
“bootstrap”
• Layer
bootstrap
• Runtime HTTP API
• context
• Lambda
Layer bootstrap
•
Layer Runtime Runtime
• Runtime
/runtime API
/invocation/next
/init/error /ID/error
/invocation/ID/response
/invocation/ID/error
bootstrap
Process events/headers
Clean up
Initialize and Invoke function
Response/Error handling
Lambda
Function
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Custom Runtime
Custom Runtime bootstrap
bootstrap
• Initialization Tasks
• Processing Tasks
Processing Task
Initialization Tasks
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Initialization Tasks
• _HANDLER
• .
• LAMBDA_TASK_ROOT
•
• AWS_LAMBDA_RUNTIME_API
• Runtime API
•
• SDK
• API
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Processing Tasks
• next invocation API
•
• API Lambda-Runtime-Trace-Id X-Ray
• _X_AMZN_TRACE_ID
• API
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Processing Tasks
•
• Invocation response API
• invocation error
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Example
#!/bin/sh
set -euo pipefail
# Initialization - load function handler
source $LAMBDA_TASK_ROOT/"$(echo $_HANDLER | cut -d. -f1).sh"
# Processing
while true
do
HEADERS="$(mktemp)"
# Get an event
EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-
01/runtime/invocation/next")
REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -
f2)
# Execute the handler function from the script
RESPONSE=$($(echo "$_HANDLER" | cut -d. -f2) "$EVENT_DATA")
# Send the response
curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-
01/runtime/invocation/$REQUEST_ID/response" -d "$RESPONSE"
done
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Runtime Interface
HTTP API
“AWS_LAMBDA_RUNTIME_API”
API
Next Invocation /runtime/invocation/next GET
Invocation Response /runtime/invocation/AwsRequestId/response POST Lambda
Invocation Error /runtime/invocation/AwsRequestId/error POST
JSON
Initialization Error /runtime/init/error POST
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Custom Runtime
Lambda
• Custom Runtime
Lambda
AWS Lambda
AWS Lambda Runtime API Runtime
•
•
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS CloudWatch Metrics
• Invocations
• Errors
• Duration
• Throttle
• etc…
AWS X-Ray
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Invocations count Lambda
≠
Duration ms Lambda 100ms )
※ Lambda
Errors count Lambda
Throttles count Throttle
Lambda
IteratorAge ms (kinesis/dynamoDB)
Lambda
DeadLetterErrors count DLQ DLQ
ConcurrentExecutions count
UnreservedConcurrentExecutions count
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Lambda
AWS Lambda /
•
• S3
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
IteratorAge Cloudwatch metrics
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
/
IteratorAge ”Average”
• Lambda
• Kinesis Streams shard
• shard shard
• 200shard
Error metrics
• Lambda
• kinesis streams latest/timestamp
•
Stream Error /
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
SQS Lambda metrics
5 580
Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda SQS
5 SQS
>
Lambda
• Lambda
• Lambda
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Throttle
• Lambda
• CloudWatch All across account Lambda
•
Error metrics
•
• SQS/ Lambda
• 1 x >
Dead Letter Queue
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS X-Ray
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS X-Ray
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Lambda X-Ray
X-Ray SDK ON
Managed policy
Python
• Python 2.7, Python3.6
Node.js
• Node.js 4.3
Java
• Java8
Go
• Go1.7
.NET
• .NET Core 2.0
CLI
--tracing-config
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
import boto3
import json
import requests
from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core import patch_all
patch_all()
def main(event, cotext):
xray_recorder.begin_segment(‘main segment’)
(main処理)
xray_recorder.begin_subsegment(‘sub segment’)
(処理A)
xray_recorder.end_subsegment(‘sub segment’)
xray_recorder.end_segment
return
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
import boto3
import json
import requests
from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core import patch_all
patch_all()
def main(event, cotext):
xray_recorder.begin_segment(‘main segment’)
(main処理)
xray_recorder.begin_subsegment(‘sub segment’)
(処理A)
xray_recorder.end_subsegment(‘sub segment’)
xray_recorder.end_segment
return
python
-botocore, boto3
-requests
-sqlite3
-mysq-connector-python
patch_all patch(’boto3’)
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
import boto3
import json
import requests
from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core import patch_all
patch_all()
def main(event, cotext):
xray_recorder.begin_segment(‘main segment’)
(main処理)
xray_recorder.begin_subsegment(‘sub segment’)
(処理A)
xray_recorder.end_subsegment(‘sub segment’)
xray_recorder.end_segment
return
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
import boto3
import json
import requests
from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core import patch_all
patch_all()
def main(event, cotext):
xray_recorder.begin_segment(‘main segment’)
(main処理)
xray_recorder.begin_subsegment(‘sub segment’)
(処理A)
xray_recorder.end_subsegment(‘sub segment’)
xray_recorder.end_segment
return
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
import boto3
import json
import requests
from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core import patch_all
patch_all()
def main(event, cotext):
xray_recorder.begin_segment(‘main segment’)
(main処理)
xray_recorder.begin_subsegment(‘sub segment’)
(処理A)
xray_recorder.end_subsegment(‘sub segment’)
xray_recorder.end_segment
return
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
•
•
•
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
X-Ray
Lambda X-Ray
X-Ray
X-Ray 16 MB
3
Lambda X-Ray
• Lambda 128 MB X-Ray
16 MB Lambda 112 MB
• 112 MB
X-Ray
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS CloudTrail
AWS CloudTrail AWS Lambda AWS
• AWS Lambda API
•
CloudTrail
AddPermission
CreateEventSourceMapping
CreateFunction
DeleteEventSourceMapping
DeleteFunction
GetEventSourceMapping
GetFunction
GetFunctionConfiguration
GetPolicy
ListEventSourceMappings
ListFunctions
RemovePermission
UpdateEventSourceMapping
UpdateFunctionCode
UpdateFunctionConfiguration
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
exports.handler =
function(event, context) {
console.log('Received event:');
var bucket =
event.Records[0].s3.bucket.name;
var key =
event.Records[0].s3.object.key;
console.log(‘Bucket: ‘+bucket);
console.log(‘Key: ‘+key);
…
CloudWatch Logs
• Lambda
/
• Max Memory Used
• Duration
• Billed Duration
• console.log
•
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
• 1
• CloudWatch Events – Schedule
• Cron
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
rate(Value Unit)
•
• Value
• Unit
• 5 => rate(5 minites)
• 1 => rate(1 hour)
• 7 => rate(7 days)
Value Unit
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
cron(Minutes Hours Day-of-month Month Day-of-week Year)
•
• UTC
•
• 10:00 => cron(0 10 * * ? *)
• 06:00 => cron(0 18 ? * MON-FRI *)
• 8:00 => cron(0 8 1 * ? *)
• 10 => cron(0/10 * ? * MON-FRI *)
• 8:00 5:55 5
=> cron(0/5 8-17 ? * MON-FRI *)
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Cron
/ minutes 0/15 15
L " " Day-of-month
Day-of-week
( )
W 5/W 5
5
5
# n 3#2 2 7 3
* Day-of-month
?
- 10-12 10 11 12
, SUN, MON, TUE
/ 5/10 5 15 25 35
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lambda
• AWS Serverless Application Repository
• Lambda
AWS CloudFormation
• AWS
AWS Serverless Application Model (AWS SAM)
•
• AWS CloudFormation
•
• CloudFomation
AWS CLI AWS SAM CLI
•
• AWS CLI
• AWS SAM CLI
5/15
Part3
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Photo credit: rolands.lakis via VisualHunt.com / CC BY
Any questions?
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Webinar
https://amzn.to/JPWebinar https://amzn.to/JPArchive

More Related Content

PDF
20190514 AWS Black Belt Online Seminar Amazon API Gateway
PDF
20180509 AWS Black Belt Online Seminar Amazon GuardDuty
PDF
20190814 AWS Black Belt Online Seminar AWS Serverless Application Model
PDF
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
PDF
AWS Black Belt Online Seminar 2017 Amazon DynamoDB
PDF
20200818 AWS Black Belt Online Seminar AWS Shield Advanced
PDF
20190130 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
PDF
20190326 AWS Black Belt Online Seminar Amazon CloudWatch
20190514 AWS Black Belt Online Seminar Amazon API Gateway
20180509 AWS Black Belt Online Seminar Amazon GuardDuty
20190814 AWS Black Belt Online Seminar AWS Serverless Application Model
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
AWS Black Belt Online Seminar 2017 Amazon DynamoDB
20200818 AWS Black Belt Online Seminar AWS Shield Advanced
20190130 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
20190326 AWS Black Belt Online Seminar Amazon CloudWatch

What's hot (20)

PDF
AWS Black Belt Online Seminar 2017 Auto Scaling
PDF
20191002 AWS Black Belt Online Seminar Amazon EC2 Auto Scaling and AWS Auto S...
PDF
20180704(20190520 Renewed) AWS Black Belt Online Seminar Amazon Elastic File ...
PDF
20190911 AWS Black Belt Online Seminar AWS Batch
PDF
AWS Black Belt Online Seminar 2017 AWS Storage Gateway
PDF
20190129 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
PDF
AWS Black Belt Online Seminar AWSで実現するDisaster Recovery
PDF
20210330 AWS Black Belt Online Seminar AWS Glue -Glue Studioを使ったデータ変換のベストプラクティス-
PDF
20210126 AWS Black Belt Online Seminar AWS CodeDeploy
PDF
20190320 AWS Black Belt Online Seminar Amazon EBS
PDF
AWS Black Belt Online Seminar 2017 Amazon Kinesis
PDF
20200526 AWS Black Belt Online Seminar AWS X-Ray
PDF
20190730 AWS Black Belt Online Seminar Amazon CloudFrontの概要
PDF
20210316 AWS Black Belt Online Seminar AWS DataSync
PDF
AWS BlackBelt Online Seminar 2017 Amazon CloudFront + AWS Lambda@Edge
PDF
20191126 AWS Black Belt Online Seminar Amazon AppStream 2.0
PPTX
20211109 bleaの使い方(基本編)
PDF
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用
PDF
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
PDF
20190226 AWS Black Belt Online Seminar Amazon WorkSpaces
AWS Black Belt Online Seminar 2017 Auto Scaling
20191002 AWS Black Belt Online Seminar Amazon EC2 Auto Scaling and AWS Auto S...
20180704(20190520 Renewed) AWS Black Belt Online Seminar Amazon Elastic File ...
20190911 AWS Black Belt Online Seminar AWS Batch
AWS Black Belt Online Seminar 2017 AWS Storage Gateway
20190129 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
AWS Black Belt Online Seminar AWSで実現するDisaster Recovery
20210330 AWS Black Belt Online Seminar AWS Glue -Glue Studioを使ったデータ変換のベストプラクティス-
20210126 AWS Black Belt Online Seminar AWS CodeDeploy
20190320 AWS Black Belt Online Seminar Amazon EBS
AWS Black Belt Online Seminar 2017 Amazon Kinesis
20200526 AWS Black Belt Online Seminar AWS X-Ray
20190730 AWS Black Belt Online Seminar Amazon CloudFrontの概要
20210316 AWS Black Belt Online Seminar AWS DataSync
AWS BlackBelt Online Seminar 2017 Amazon CloudFront + AWS Lambda@Edge
20191126 AWS Black Belt Online Seminar Amazon AppStream 2.0
20211109 bleaの使い方(基本編)
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
20190226 AWS Black Belt Online Seminar Amazon WorkSpaces
Ad

Similar to 20190402 AWS Black Belt Online Seminar Let's Dive Deep into AWS Lambda Part1 & Part2 (20)

PDF
AWS Black Belt Online Seminar AWS 認定クラウドプラクティショナー取得に向けて
PDF
20191023 AWS Black Belt Online Seminar Amazon EMR
PDF
20190306 AWS Black Belt Online Seminar Amazon EC2 スポットインスタンス
PDF
Aws lambda webinar -buraku
PDF
Aws seminar report
PDF
Microservices for Startups - Donnie Prakoso - AWS - CC18
PDF
AWS Certified Solutions Architect Associate Notes.pdf
PDF
マイクロサービスを AWS サーバレス&コンテナで実装する方法
PPTX
Using GitHub actions on AWS.pptx
PDF
Aws tkv-ug
PDF
Serverless best practices plus design principles 20m version
PDF
GitHub to Lambda: Developing, testing and deploying serverless apps::Faten He...
PPTX
re:Invent 2018 re:Cap for Toronto AWS User Group
PDF
Serverless applications with AWS
PDF
2018512 AWS上での機械学習システムの構築とSageMaker
PDF
20190306 AWS Black Belt Online Seminar Amazon EC2スポットインスタンス
PDF
Introduction to AWS
PDF
20190318 Amazon EC2 スポットインスタンス再入門
PDF
AWS における サーバーレスの基礎からチューニングまで
PDF
Re cap2018
AWS Black Belt Online Seminar AWS 認定クラウドプラクティショナー取得に向けて
20191023 AWS Black Belt Online Seminar Amazon EMR
20190306 AWS Black Belt Online Seminar Amazon EC2 スポットインスタンス
Aws lambda webinar -buraku
Aws seminar report
Microservices for Startups - Donnie Prakoso - AWS - CC18
AWS Certified Solutions Architect Associate Notes.pdf
マイクロサービスを AWS サーバレス&コンテナで実装する方法
Using GitHub actions on AWS.pptx
Aws tkv-ug
Serverless best practices plus design principles 20m version
GitHub to Lambda: Developing, testing and deploying serverless apps::Faten He...
re:Invent 2018 re:Cap for Toronto AWS User Group
Serverless applications with AWS
2018512 AWS上での機械学習システムの構築とSageMaker
20190306 AWS Black Belt Online Seminar Amazon EC2スポットインスタンス
Introduction to AWS
20190318 Amazon EC2 スポットインスタンス再入門
AWS における サーバーレスの基礎からチューニングまで
Re cap2018
Ad

More from Amazon Web Services Japan (20)

PDF
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
PDF
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
PDF
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
PDF
Infrastructure as Code (IaC) 談義 2022
PDF
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
PDF
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
PDF
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
PPTX
20220409 AWS BLEA 開発にあたって検討したこと
PDF
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
PDF
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
PDF
Amazon QuickSight の組み込み方法をちょっぴりDD
PDF
マルチテナント化で知っておきたいデータベースのこと
PDF
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
PDF
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
PDF
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
PDF
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
PDF
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
PPTX
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
PDF
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
PDF
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
Infrastructure as Code (IaC) 談義 2022
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
20220409 AWS BLEA 開発にあたって検討したこと
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
Amazon QuickSight の組み込み方法をちょっぴりDD
マルチテナント化で知っておきたいデータベースのこと
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
A Presentation on Artificial Intelligence
PPT
Teaching material agriculture food technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Machine learning based COVID-19 study performance prediction
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
The Rise and Fall of 3GPP – Time for a Sabbatical?
NewMind AI Weekly Chronicles - August'25 Week I
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Understanding_Digital_Forensics_Presentation.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Electronic commerce courselecture one. Pdf
Network Security Unit 5.pdf for BCA BBA.
Unlocking AI with Model Context Protocol (MCP)
Reach Out and Touch Someone: Haptics and Empathic Computing
A Presentation on Artificial Intelligence
Teaching material agriculture food technology
Chapter 3 Spatial Domain Image Processing.pdf
Big Data Technologies - Introduction.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Spectral efficient network and resource selection model in 5G networks
Machine learning based COVID-19 study performance prediction
20250228 LYD VKU AI Blended-Learning.pptx
Review of recent advances in non-invasive hemoglobin estimation

20190402 AWS Black Belt Online Seminar Let's Dive Deep into AWS Lambda Part1 & Part2

  • 1. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Webinar https://amzn.to/JPWebinar https://amzn.to/JPArchive Solutions Architect 2019/04/09 Let’s Dive Deep into AWS Lambda [AWS Black Belt Online Seminar] Part1 & Part2
  • 2. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark • 2019 4 1 AWS (http://aws.amazon.com) • AWS AWS • • AWS does not offer binding price quotes. AWS pricing is publicly available and is subject to change in accordance with the AWS Customer Agreement available at http://aws.amazon.com/agreement/. Any pricing information included in this document is provided only as an estimate of usage charges for AWS services based on certain information that you have provided. Monthly charges will be based on your actual use of AWS services, and may vary from the estimates provided.
  • 3. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Who am I ? Keisuke Nishitani Manager, Specialist Solutions Architect Amazon Web Service Japan K.K @Keisuke69 Keisuke69 Keisuke69 Keisuke69Keisuke69x
  • 4. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Lambda AWS Lambda /
  • 5. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 6. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 7. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 8. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Photo credit: Ajith (അജിത്ത്) via Visualhunt / CC BY-SA
  • 9. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Photo credit: Leo Hidalgo (@yompyz) via VisualHunt / CC BY
  • 10. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 11. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark • OS • • • •
  • 12. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Undifferentiated Heavy Lifting
  • 13. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Photo credit: kizzzbeth via Visual hunt / CC BY
  • 14. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Developers need …
  • 15. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark More efficiency More scalability More agility
  • 16. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark And…
  • 17. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark No more servers
  • 18. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Lambda AWS Lambda /
  • 19. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 20. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark LEVELOFABSTRACTIONComputing
  • 21. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark • • • • • LEVELOFABSTRACTIONComputing
  • 22. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Virtual Servers in Datacenters LEVELOFABSTRACTIONComputing • HW • • • Elastic • •
  • 23. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Virtual Servers in Datacenters Virtual Servers in Datacenters LEVELOFABSTRACTIONComputing • • • • • • ( )
  • 24. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Virtual Servers in Datacenters Virtual Servers in Datacenters Serverless • • • • • AWS Lambda AWS Fargate LEVELOFABSTRACTIONComputing
  • 25. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 26. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 27. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark / / •
  • 28. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark •
  • 29. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda
  • 30. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Compute スケールの単位 インスタンス アプリケーション 関数 抽象化 ハードウェア OS ランタイム 使いドコロ • OS、ネットワーク、スト レージのレベルで構成を制御 したい • 好みのOSを利用したい • OS以上の全てを自分でコン トロールしたい • サーバを自分で構成して実行 したい • アプリケーションの構成を制 御したい • スケールを自分でコントロー ルしたい • 必要なときだけコードの実行 を行いたい • インフラの構成・管理を行い たくない Amazon EC2 Container Services AWS Lambda
  • 31. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Lambda release history ? *As of October 2018, does not include region launches 2015 2016 2017 2018
  • 32. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark API Gateway S3 Amazon Kinesis Data Streams SQS S3 DynamoDB
  • 33. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark SECURITY DEV TOOLS MONITORING EVENT SOURCES DOWN STREAMS AWS Cloud9 AWS SAM AWS CodeBuild AWS CodePipeline AWS CodeDeploy AWS CodeCommit AWS SAM CLI AWS X-Ray AWS CodeStar Amazon S3 Amazon Kinesis Amazon DynamoDB Amazon SQS Amazon API Gateway AWS CloudWatch AWS CloudWatch Logs AWS Config AWS IAMAWS WAFAmazon Cognito Amazon SNS Amazon SES AWS IoT AWS AppSync Amazon Lex AWS CloudWatch Events Amazon S3 Amazon DynamoDB Any AWS Services External API AWS Lambda AWS Step Functions AWS Amplify
  • 34. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark 0.0% 10.0% 20.0% 30.0% 40.0% 50.0% 60.0% 70.0% 80.0% 90.0% 100.0% Google Kubernetes Engine Google Firebase Amazon SageMaker AWS IoT Amazon Redshift (Spectrum) Amazon Kinesis Data Firehose Amazon Fargate Amazon SQS Amazon Kinesis Data Streams AWS Step Functions Amazon Cognito Amazon ECS Amazon Aurora Amazon DynamoDB Amazon API Gateway AWS Lambda
  • 35. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark 0.0% 5.0% 10.0% 15.0% 20.0% 25.0% 30.0% 35.0% 40.0% 45.0% インタラクティブモバイル 0.その他 画像データ加⼯処理 外部向けサービスの認証機能 IoT関連領域 チャットボット、Alexaスキル 企業内データの収集・加⼯処理 業務系API、グループ企業間API イベント駆動の業務間連携 モバイルバックエンド ログデータ処理、機械学習ELTデータパイプライン 動的Webシステム
  • 36. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Lambda AWS Lambda /
  • 37. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Lambda
  • 38. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda AWS Lambda • • 1 • JSON • ZIP • Amazon S3 • S3 ARN
  • 39. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark 2019 4 1 Python 2.7, 3.6, 3.7 Node.js 6.10, 8.10 .NET Core 1.0(C#), 2.0(C#), 2,1(C#/PowerShell 6.0) Go 1.x Java 8 Ruby 2.5
  • 40. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda - • 64MB 128MB 3008MB • CPU • • Lambda • 900 15 • AWS IAM • IAM Lambda AWS
  • 41. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda TCP/IP UDP/IP ptrace TCP 25
  • 42. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Lambda : Amazon Linux AMI: amzn-ami-hvm-2017.03.1.20170812-x86_64-gp2 Linux : 4.14.77-70.59.amzn1.x86_64 AWS SDK for JavaScript: 2.290.0 SDK for Python (Boto 3) • Python 3.6: boto3-1.7.74 botocore-1.10.74 • Python 3.7: boto3-1.9.42 botocore-1.12.42
  • 43. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS • Lambda 3 • • • Lambda Lambda • • Lambda • AWS Lambda
  • 44. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark 2019 4 1 Amazon S3 Amazon DynamoDB Amazon Kinesis Data Streams Amazon Simple Notification Service Amazon Simple Email Service Amazon Simple Queue Service Amazon Cognito AWS CloudFormation Amazon CloudWatch Logs Amazon CloudWatch AWS CodeCommit Schedlued Event(Amazon CloudWatch Events ) AWS Config Amazon Alexa Amazon Lex Amazon API Gateway AWS IoT Amazon CloudFront Amazon Kinesis Data Firehose
  • 45. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS CLI • AWS • InvocationType Event • • InvocationType RequestResponse • Lambda
  • 46. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda • • FunctionError • Limit URL https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/API_Invoke.html#API_Invok e_Errors • AWS • • 2 • • Dead Letter Queue DLQ Amazon SQS Amazon SNS
  • 47. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda • • • Visibility Timeout •
  • 48. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark VPC Amazon RDS Amazon Elasticache VPC VPC Lambda VPC • • Availbility Zone (AZ) 1 • AZ IP AZ Lambda Elastic Network Interface(ENI) • Lambda • ENI IP DHCP • IAM Role ”AWSLambdaVPCAccessExecutionRole”
  • 49. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark VPC • IP • NAT Amazon VPC NAT ENI IP • CloudWatch Logs • ENI Projected peak concurrent executions * (Memory in GB / 3GB)
  • 50. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark VPC FAQ IP ENI Lambda IP VPC Managed Nat Gateway NAT IP
  • 51. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark VPC FAQ Lambda Lambda AWS Direct Connect VPN Lambda ENI 10 60 ENI Lambda ENI Lambda
  • 52. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark - Lambda AWS • Amazon CloudWatch Logs • Lambda Lambda • AWS Identity and Access Management (IAM) • ”AWS Lambda” • Lambda AWS • Lambda
  • 53. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark - AWSLambdaBasicExecutionRole • CloudWatch AWSLambdaKinesisExecutionRole • Amazon Kinesis AWSLambdaDynamoDBExecutionRole • Amazon DynamoDB AWSLambdaSQSQueueExecutionRole • Amazon Simple Queue Service (Amazon SQS) AWSLambdaVPCAccessExecutionRole • VPC Elastic Network Interface AWSXrayWriteOnlyAccess • X-Ray
  • 54. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark - Lambda • • AWS Lambda AWS • principal AWS ID IAM
  • 55. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda 1,000 • ( : 429) • 15 30 ConcurrentExecutions UnreservedConcurrentExecutions
  • 56. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark • • • Amazon SQS 5 1 60 •
  • 57. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark 1s 2s 3s 4s 5s 秒間リクエスト: 10 req/sec 関数の平均実行時間: 3s / exec 同時実行数 = “同時”に実行されているタイミング
  • 58. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark - 同時実行数 ストリーム シャード1 シャード2 シャード3
  • 59. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark 1 500 • 1000 • 10,000 10,000 • ” ”
  • 60. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda 1. ENI 2. 3. 4. 5. 6. / 7. • VPC • 10 30 • Duration
  • 61. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda 1. ENI 2. 3. 4. 5. 6. / 7. • • S3 ZIP • Duration
  • 62. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda 1. ENI 2. 3. 4. 5. 6. / 7. • • • Duration
  • 63. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda 1. ENI 2. 3. 4. 5. 6. / 7. • / • Duration
  • 64. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda 1. ENI 2. 3. 4. 5. 6. / 7. • Lambda
  • 65. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda 1. ENI 2. 3. 4. 5. 6. / 7.
  • 66. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda 1. ENI 2. 3. 4. 5. 6. / 7.
  • 67. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda 1. ENI 2. 3. 4. 5. 6. / 7.
  • 68. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda 1. ENI 2. 3. 4. 5. 6. / 7. 1~6
  • 69. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark • 1 • • •
  • 70. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark • 1 • • •
  • 71. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda freeze • •
  • 72. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 73. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark • 1000 75GB
  • 74. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark 128 MB 3008 MB 64 MB 900 seconds (15 ) 4 KB 20 KB 5 layers ( ) 6 MB ( ) 256 KB ( ) 50 MB (zip ) 250 MB ( : ) 3 MB ( ) ( ) 10 /tmp 512 MB 1024 / 1024
  • 75. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 76. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark ( ) • 100 • $0.20/100 (1 $0.0000002) ( ) • 100ms 100ms • ) 128MB $ 0.000000208/100ms • 1GB 1 $0.00001667 • http://qiita.com/Keisuke69/items/e3f79b50b6039175401b
  • 77. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Lambda AWS Lambda /
  • 78. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Lambda
  • 79. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 80. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark • • Lambda • JSON • • 2 • • true • false callback
  • 81. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark • Lambda • AWS CloudWatch Logs • • CloudWatch Logs • • Lambda • • Lambda
  • 82. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda • Amazon S3 Amazon DynamoDB
  • 83. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark • Python Node.js Lambda Lambda • Serverless Application Repository • •
  • 84. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 85. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda • • • • •
  • 86. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda Node.js https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/programming-model.html Python https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/python-programming-model.html Java https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/java-programming-model.html Go https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/go-programming-model.html C# https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/dotnet-programming-model.html PowerShell https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/powershell-programming-model.html Ruby https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/lambda-ruby.html
  • 87. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Cloud9 • Lambda
  • 88. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark .zip .jar • zip • ) Node.js node_modules zip • https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/deployment-package-v2.html Lambda • $ zipinfo test.zip Archive: test.zip Zip file size: 473 bytes, number of entries: 2 -r--r--r-- 3.0 unx 0 bx stor 17-Aug-10 09:37 exlib.py -r--r--r-- 3.0 unx 234 tx defN 17-Aug-10 09:37 index.py 2 files, 234 bytes uncompressed, 163 bytes compressed: 30.3%
  • 89. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda
  • 90. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark 1000 • A 100 • B 200 • 700(1000-100-200=700) DB API ENI/IP
  • 91. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 92. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark • • DB URL 2 Lambda • • Node.js process.env Lambda
  • 93. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Key Management Service AWS KMS • Lambda KMS • • • Lambda • • • AWS KMS • kms:Decrypt • • Lambda • Lambda
  • 94. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 95. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda _HANDLER AWS_REGION Lambda AWS AWS_EXECUTION_ENV AWS_Lambda_ AWS_Lambda_java8 AWS_LAMBDA_FUNCTION_NAME AWS_LAMBDA_FUNCTION_MEMORY_SIZE (MB ) AWS_LAMBDA_FUNCTION_VERSION AWS_LAMBDA_LOG_GROUP_NAME AWS_LAMBDA_LOG_STREAM_NAME Amazon CloudWatch Logs AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN LANG en_US.UTF-8 TZ (UTC) NTP LAMBDA_TASK_ROOT Lambda LAMBDA_RUNTIME_DIR PATH /usr/local/bin:/usr/bin/:/bin:/opt/bin LD_LIBRARY_PATH /lib64:/usr/lib64:$LAMBDA_RUNTIME_DIR:$LAMBDA_RUNTIME_DIR/lib:$LAMBDA_TASK_ ROOT:$LAMBDA_TASK_ROOT/lib:/opt/lib NODE_PATH (Node.js) /opt/nodejs/node8/node_modules/:/opt/nodejs/node_modules:$LAMBDA_RUN TIME_DIR/node_modules PYTHONPATH (Python) $LAMBDA_RUNTIME_DIR. GEM_PATH (Ruby) $LAMBDA_TASK_ROOT/vendor/bundle/ruby/2.5.0:/opt/ruby/gems/2.5.0. AWS_LAMBDA_RUNTIME_API ( ) API
  • 96. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark 4KB • [a-zA-Z] • ([a-zA-Z0-9_] ) • AWS Lambda ) Lang, LD_LIBRARY_PATH
  • 97. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda • ARN • Lambda / publish • PublishVersion • $LATEST • • exports.handler = function(event,context) {context.succeed(“bye”);} exports.handler = function(event,context) {context.succeed(“hi”);}
  • 98. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark • • •
  • 99. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark routing-config 2 % 1. 2 2. 98 3. 4.
  • 100. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark : • FunctionName • FunctionName:$LATEST • FunctionName:1 • FunctionName:2 : • FunctionName:production • FunctionName:v1_2_3_4
  • 101. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda Layers Lambda Lambda Layer Layer
  • 102. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda Layers ZIP Lambda Layer Layers immutable 5 Layers Layer Lambda Layers arn:aws:lambda:region:accountId:layer:shared-lib Lambda Layers arn:aws:lambda:region:accountId:layer:shared-lib:2 Lambda Layers arn:aws:lambda:region:accountId:layer:shared-lib:3
  • 107. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda Layers /opt • • Layer 1 5 • 250MB • Layer zip or S3 /opt • Python – python, python/lib/python3.7/site-packages (site directories) • Node.js – nodejs/node_modules, nodejs/node8/node_modules (NODE_PATH) https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html
  • 108. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda • Lambda • Lambda AWS AWS CLI
  • 109. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 110. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark DLQ 2 Amazon SQS Amazon SNS • • Amazon SQS: SendMessage • Amazon SNS: Publish
  • 111. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark DLQ DLQ DLQ DeadLetterErrors RequestID ID ErrorCode 3 HTTP ErrorMessage (1 KB )
  • 112. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Custom Runtimes Linux Lambda Runtime API AWS C++/Rust OSS https://github.com/awslabs/aws-lambda-cpp-runtime https://github.com/awslabs/aws-lambda-rust-runtime PHP/Erlang/Elixir/COBOL provided
  • 113. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Runtime bootstrap “bootstrap” • Layer bootstrap • Runtime HTTP API • context • Lambda Layer bootstrap • Layer Runtime Runtime • Runtime /runtime API /invocation/next /init/error /ID/error /invocation/ID/response /invocation/ID/error bootstrap Process events/headers Clean up Initialize and Invoke function Response/Error handling Lambda Function
  • 114. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Custom Runtime Custom Runtime bootstrap bootstrap • Initialization Tasks • Processing Tasks Processing Task Initialization Tasks
  • 115. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Initialization Tasks • _HANDLER • . • LAMBDA_TASK_ROOT • • AWS_LAMBDA_RUNTIME_API • Runtime API • • SDK • API
  • 116. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Processing Tasks • next invocation API • • API Lambda-Runtime-Trace-Id X-Ray • _X_AMZN_TRACE_ID • API
  • 117. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Processing Tasks • • Invocation response API • invocation error •
  • 118. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Example #!/bin/sh set -euo pipefail # Initialization - load function handler source $LAMBDA_TASK_ROOT/"$(echo $_HANDLER | cut -d. -f1).sh" # Processing while true do HEADERS="$(mktemp)" # Get an event EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06- 01/runtime/invocation/next") REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: - f2) # Execute the handler function from the script RESPONSE=$($(echo "$_HANDLER" | cut -d. -f2) "$EVENT_DATA") # Send the response curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06- 01/runtime/invocation/$REQUEST_ID/response" -d "$RESPONSE" done
  • 119. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Runtime Interface HTTP API “AWS_LAMBDA_RUNTIME_API” API Next Invocation /runtime/invocation/next GET Invocation Response /runtime/invocation/AwsRequestId/response POST Lambda Invocation Error /runtime/invocation/AwsRequestId/error POST JSON Initialization Error /runtime/init/error POST
  • 120. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Custom Runtime Lambda • Custom Runtime Lambda AWS Lambda AWS Lambda Runtime API Runtime • • •
  • 121. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS CloudWatch Metrics • Invocations • Errors • Duration • Throttle • etc… AWS X-Ray
  • 122. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Invocations count Lambda ≠ Duration ms Lambda 100ms ) ※ Lambda Errors count Lambda Throttles count Throttle Lambda IteratorAge ms (kinesis/dynamoDB) Lambda DeadLetterErrors count DLQ DLQ ConcurrentExecutions count UnreservedConcurrentExecutions count
  • 123. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Lambda AWS Lambda / • • S3
  • 124. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 125. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark IteratorAge Cloudwatch metrics
  • 126. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark / IteratorAge ”Average” • Lambda • Kinesis Streams shard • shard shard • 200shard Error metrics • Lambda • kinesis streams latest/timestamp • Stream Error /
  • 127. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark SQS Lambda metrics 5 580 Lambda
  • 128. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda SQS 5 SQS > Lambda • Lambda • Lambda
  • 129. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Throttle • Lambda • CloudWatch All across account Lambda • Error metrics • • SQS/ Lambda • 1 x > Dead Letter Queue •
  • 130. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS X-Ray
  • 131. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS X-Ray
  • 132. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Lambda X-Ray X-Ray SDK ON Managed policy Python • Python 2.7, Python3.6 Node.js • Node.js 4.3 Java • Java8 Go • Go1.7 .NET • .NET Core 2.0 CLI --tracing-config
  • 133. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark import boto3 import json import requests from aws_xray_sdk.core import xray_recorder from aws_xray_sdk.core import patch_all patch_all() def main(event, cotext): xray_recorder.begin_segment(‘main segment’) (main処理) xray_recorder.begin_subsegment(‘sub segment’) (処理A) xray_recorder.end_subsegment(‘sub segment’) xray_recorder.end_segment return
  • 134. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark import boto3 import json import requests from aws_xray_sdk.core import xray_recorder from aws_xray_sdk.core import patch_all patch_all() def main(event, cotext): xray_recorder.begin_segment(‘main segment’) (main処理) xray_recorder.begin_subsegment(‘sub segment’) (処理A) xray_recorder.end_subsegment(‘sub segment’) xray_recorder.end_segment return python -botocore, boto3 -requests -sqlite3 -mysq-connector-python patch_all patch(’boto3’)
  • 135. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark import boto3 import json import requests from aws_xray_sdk.core import xray_recorder from aws_xray_sdk.core import patch_all patch_all() def main(event, cotext): xray_recorder.begin_segment(‘main segment’) (main処理) xray_recorder.begin_subsegment(‘sub segment’) (処理A) xray_recorder.end_subsegment(‘sub segment’) xray_recorder.end_segment return
  • 136. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark import boto3 import json import requests from aws_xray_sdk.core import xray_recorder from aws_xray_sdk.core import patch_all patch_all() def main(event, cotext): xray_recorder.begin_segment(‘main segment’) (main処理) xray_recorder.begin_subsegment(‘sub segment’) (処理A) xray_recorder.end_subsegment(‘sub segment’) xray_recorder.end_segment return
  • 137. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark import boto3 import json import requests from aws_xray_sdk.core import xray_recorder from aws_xray_sdk.core import patch_all patch_all() def main(event, cotext): xray_recorder.begin_segment(‘main segment’) (main処理) xray_recorder.begin_subsegment(‘sub segment’) (処理A) xray_recorder.end_subsegment(‘sub segment’) xray_recorder.end_segment return
  • 138. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark • • • •
  • 139. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark X-Ray Lambda X-Ray X-Ray X-Ray 16 MB 3 Lambda X-Ray • Lambda 128 MB X-Ray 16 MB Lambda 112 MB • 112 MB X-Ray
  • 140. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS CloudTrail AWS CloudTrail AWS Lambda AWS • AWS Lambda API • CloudTrail AddPermission CreateEventSourceMapping CreateFunction DeleteEventSourceMapping DeleteFunction GetEventSourceMapping GetFunction GetFunctionConfiguration GetPolicy ListEventSourceMappings ListFunctions RemovePermission UpdateEventSourceMapping UpdateFunctionCode UpdateFunctionConfiguration
  • 141. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark exports.handler = function(event, context) { console.log('Received event:'); var bucket = event.Records[0].s3.bucket.name; var key = event.Records[0].s3.object.key; console.log(‘Bucket: ‘+bucket); console.log(‘Key: ‘+key); … CloudWatch Logs • Lambda / • Max Memory Used • Duration • Billed Duration • console.log •
  • 142. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark • 1 • CloudWatch Events – Schedule • Cron
  • 143. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 144. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark rate(Value Unit) • • Value • Unit • 5 => rate(5 minites) • 1 => rate(1 hour) • 7 => rate(7 days) Value Unit
  • 145. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark cron(Minutes Hours Day-of-month Month Day-of-week Year) • • UTC • • 10:00 => cron(0 10 * * ? *) • 06:00 => cron(0 18 ? * MON-FRI *) • 8:00 => cron(0 8 1 * ? *) • 10 => cron(0/10 * ? * MON-FRI *) • 8:00 5:55 5 => cron(0/5 8-17 ? * MON-FRI *)
  • 146. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Cron / minutes 0/15 15 L " " Day-of-month Day-of-week ( ) W 5/W 5 5 5 # n 3#2 2 7 3 * Day-of-month ? - 10-12 10 11 12 , SUN, MON, TUE / 5/10 5 15 25 35
  • 147. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
  • 148. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Lambda • AWS Serverless Application Repository • Lambda AWS CloudFormation • AWS AWS Serverless Application Model (AWS SAM) • • AWS CloudFormation • • CloudFomation AWS CLI AWS SAM CLI • • AWS CLI • AWS SAM CLI 5/15 Part3
  • 149. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark Photo credit: rolands.lakis via VisualHunt.com / CC BY Any questions?
  • 150. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark AWS Webinar https://amzn.to/JPWebinar https://amzn.to/JPArchive