Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
aws-lambda-in-practice
Search
tannai
February 20, 2016
Technology
2
1.9k
aws-lambda-in-practice
tannai
February 20, 2016
Tweet
Share
More Decks by tannai
See All by tannai
redash patche at dmm
yuukigoodman
0
680
akibago-2018-10-30
yuukigoodman
0
67
serverless-design-and-streaming-date-processing-service
yuukigoodman
0
860
alexa-changes-development-process
yuukigoodman
0
1.3k
VUIとAlexaによるちょっと未来の体験の話2
yuukigoodman
0
780
regrowth2016alexa
yuukigoodman
0
1.1k
Rails App Deployment with CodeDeploy
yuukigoodman
0
1.3k
cognito-userpools-in-production
yuukigoodman
4
8.4k
serverless-from-today
yuukigoodman
2
2k
Other Decks in Technology
See All in Technology
Lexical Analysis
shigashiyama
1
150
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
2
1.7k
FlutterアプリにおけるSLI/SLOを用いたユーザー体験の可視化と計測基盤構築
ostk0069
0
100
AWS Lambda のトラブルシュートをしていて思うこと
kazzpapa3
2
180
日経電子版のStoreKit2フルリニューアル
shimastripe
1
140
複雑なState管理からの脱却
sansantech
PRO
1
150
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
180
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
190
AWS Media Services 最新サービスアップデート 2024
eijikominami
0
200
Flutterによる 効率的なAndroid・iOS・Webアプリケーション開発の事例
recruitengineers
PRO
0
120
アジャイルでの品質の進化 Agile in Motion vol.1/20241118 Hiroyuki Sato
shift_evolve
0
170
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
250
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
BBQ
matthewcrist
85
9.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Speed Design
sergeychernyshev
25
620
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
Transcript
%FWFMPQFST*0 -B ୮༏لϞόΠϧΞϓϦαʔϏε෦ Ϋϥεϝιουגࣜձࣾ ⡥$MBTTNFUIPE *OD ݄ ࣮Ͱ͏"84-BNCEB #cmdevio2016
#La
ࣗݾհ • ୮༏ل • Ϋϥεϝιουגࣜձࣾ • ϞόΠϧΞϓϦαʔϏε෦ • αʔόαΠυ୲ 2
#cmdevio2016 #La
ϞόΠϧόοΫΤϯυάϧʔϓ • AWSͱiOS/Androidͷهࣄ͕ଟ͍Classmethod • ࢢͷมԽʹରԠͯ͠αʔόαΠυͷ։ൃ ڧԽ • AWS্Ͱಈ͘APIαʔόWebΞϓϦͷ։ൃ • ্ཱͪ͛ظʹ͖ͭืूதʂ
3 #cmdevio2016 #La
ຊ 4
Agenda • AWS Lambdaͱ࣮ • ࣮ͰͷϢʔεέʔε • LambdaͷTips • ࣮ʹΈࠐΉצॴ
5
AWS Lambdaͱ • https://aws.amazon.com/jp/lambda/faqs/ • ొͨ͠ϓϩάϥϜΛ࣮ߦͯ͘͠ΕΔ ϑϧϚωʔδυαʔϏε • EC2ͷΑ͏ͳཧ͢Βෆཁ •
ϑϧϚωʔδυ • AWSͱͷ࿈ܞ͕ڧྗ • Πϕϯτιʔε 6 #cmdevio2016 #La
࣮ͱ • ࣮ࡍͷ۩ମతͳࣄ • https://kotobank.jp/word/࣮-521746 • ʮΛՌ͓ͨͯۚ͠ΛΒ͏ʯ • ظݶ/είʔϓ/༧ࢉͷ͍͔͕ܾͭ͘·͍ͬͯΔ 7
#cmdevio2016 #La
ͪΐͬͱͰLambdaΛ ͬͨ͜ͱ͕͋Δਓ 8
࣮ͰLambdaΛ ͍ͬͯΔਓ 9
࣮ͰLambdaΛ ͕ͬͭΓ͍ͬͯΔਓ 10
࣮ͰLambdaΛ͏ͷ͍͠ʁ • Lambda͕ྑͦ͞͏ͳ͜ͱ͔Δ • EC2ͰΦϯϓϨͱಉ͡Α͏ʹϓϩάϥϜΛ ࣮ߦ͢Δ͜ͱ͕Ͱ͖ͨ • Lambdaͷ͍ํɺͦΕͱҟͳΔ • ೲظ͕ܾ·͍ͬͯΔͷͰԼखʹϋϚΔͱਏ͍
• ӡ༻࣌ʹ͕ग़ΔͱࠔΔ 11 #cmdevio2016 #La
͜ͷηογϣϯͷΰʔϧ • LambdaΛ࣮Ͱ͏͖͔͚ͬʹͳΔ • ࣮ʹແཧͳ͘औΓೖΕΒΕΔઃܭͷ ͖͔͚ͬΛಘΔ 12 #cmdevio2016 #La
Agenda • AWS Lambdaͱ࣮ • ࣮ͰͷϢʔεέʔε • LambdaͷTips • ࣮ʹΈࠐΉצॴ
13
S3ϑΝΠϧૢ࡞ 14
S3ϑΝΠϧૢ࡞ • ϝλσʔλ༩ • αϜωΠϧ࡞ 15 #cmdevio2016 #La
CSVͷDynamoDBςʔϒϧԽ 16
CSVͷDynamoDBςʔϒϧԽ • S3ʹΞοϓϩʔυ͞ΕͨCSVϑΝΠϧΛ DynamoDBςʔϒϧʹॻ͖ࠐΉFunction • FunctionΛ࣮ߦ͢ΔFunctionͰಉ࣮࣌ߦΛ ੍ޚ 17 #cmdevio2016 #La
CSVͷDynamoDBςʔϒϧԽ 18 #cmdevio2016 #La
CSVͷDynamoDBςʔϒϧԽ • ͱΞϓϦͷػೳͱͯ͠ߟ͍͑ͯͨ • ࣌ؒͷ͔͔ΔॲཧͩͬͨͷͰLambdaԽ • workerͰྑ͔͕ͬͨLambdaͷํ͕ ӡ༻͠ͳͯ͘ྑ͍ͿΜָ 19 #cmdevio2016
#La
ϞόΠϧΞϓϦ͔ΒݺͿAPI 20
ϞόΠϧΞϓϦ͔ΒݺͿAPI • APIαʔό͕୲͍ͬͯͨॲཧΛLambdaͰߦ͏ • DynamoDBʹॻ͖ࠐΉΑΓ༻్͕͍ • ϩδοΫΛޙ͔ΒมߋͰ͖Δ • ηΩϡϦςΟ্ͪΐͬͱ҆৺ 21
#cmdevio2016 #La
ϞόΠϧΞϓϦ͔ΒݺͿAPI 22 #cmdevio2016 #La
ϞόΠϧΞϓϦ͔ΒݺͿAPI 23 #cmdevio2016 #La
ϞόΠϧΞϓϦ͔ΒݺͿAPI • ݁ہɺཁ͕݅ᐆດͳஈ֊ͰLambda࠾༻Λ ܾஅͰ͖ͳ͔ͬͨ • APIαʔόΛNode.jsͰॻ͍ͯਐΊΔ • ཁ͕݅ݻ·ͬͨΓɺLambdaͷػೳ֦ு ΞΫηε͕ݟ௨ͤͨΒLambdaʹ͢Δ ͔͠Εͳ͍
24 #cmdevio2016 #La
σʔλͷऩू 25
σʔλͷऩू • KinesisʹLambdaͰσʔλΛS3ʹஷΊΔ • ஷΊͨσʔλόονͰRDSRedshift • PullܕͰىಈ͢ΔͷͰϨίʔυཧ͕ෆཁ • Lambdaͷػೳ֦ுͱڞʹมԽ 26
#cmdevio2016 #La
σʔλͷऩू 27 Firehoseొલ #cmdevio2016 #La
σʔλͷऩू 28 Firehoseొޙ #cmdevio2016 #La
CloudFormation 29
CloudFormation • https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/ template-custom-resources-lambda.html 30 #cmdevio2016 #La
Agenda • AWS Lambdaͱ࣮ • ࣮ͰͷϢʔεέʔε • LambdaͷTips • ࣮ʹΈࠐΉצॴ
31
όʔδϣχϯάͱΤΠϦΞε 32
όʔδϣχϯάͱΤΠϦΞε • όʔδϣϯ • ಉ͡FunctionͰ൛͝ͱʹมΘΔARN • ΤΠϦΞε • ඥͮ͘όʔδϣϯΛมߋͰ͖ΔARN •
͜ΕΒΛͬͯLambda FunctionΛཧ͢Δ 33 #cmdevio2016 #La
όʔδϣχϯάͱΤΠϦΞε 34 #cmdevio2016 #La
σϓϩΠ 35
σϓϩΠ • ϑΝΠϧΛzipͨ͠ΞϓϦέʔγϣϯόϯυϧ Λ࡞ͬͯΞοϓϩʔυ • Functionຊମ • ґଘϥΠϒϥϦ • aws-sdkaws-cliΛϥοϓ͢Δͱྑ͍
36 #cmdevio2016 #La
σϓϩΠ 37 σϓϩΠύοέʔδʹؚΊΔϥΠϒϥϦͷऔಘ #cmdevio2016 #La
σϓϩΠ 38 σϓϩΠύοέʔδͷΞοϓϩʔυ #cmdevio2016 #La
σϓϩΠ • ϚωδϝϯτίϯιʔϧͰΤΠϦΞεͷΓ ସ͑ 39 #cmdevio2016 #La
ࢹͱϦΧόϦ 40
ࢹͱϦΧόϦ • CloudWatchͰLambdaϝτϦΫεΛݟ͓ͯ͘ • ࣮ߦ݁Ռ͔Βҟৗ͕Θ͔Δͱϕετ • ҟৗ͕͋ͬͨΒϦτϥΠͰ͖ΔΑ͏ʹͯ͠ ͓͘ 41 #cmdevio2016
#La
ࢹͱϦΧόϦ • Lambdaࣗମ͕མͪͨ͜ͱແ͍ • ↑ݸਓͷײͰ͢ • ΞϓϦಉ༷ɺFunctionͷόά͔Βͷෆ۩߹ • ྫ֎Λर͑ͯͳ͔ͬͨɺͳͲ •
࣮ߦ݁Ռ͔Βෆ۩߹Λݕ • ࣄલʹܾΊͨ௨ΓͷϦτϥΠͰରԠ 42 #cmdevio2016 #La
Ϧϛοτ 43
Ϧϛοτ • http://docs.aws.amazon.com/ja_jp/lambda/ latest/dg/limits.html • ࣮༻্ϝϞϦͱಉ࣮࣌ߦͱαΠζʹҙ • ಉظݺͼग़͠ௐ͞ΕΔͱΤϥʔ͕ฦΔ 44 #cmdevio2016
#La
LambdaόοΫΤϯυͷฒྻੑ 45
LambdaόοΫΤϯυͷฒྻੑ • Functionɺฒྻͤ͞ΒΕΔΑ͏ʹॻ͘લఏ • Lambdaࣗମྑ͍͕ɺόοΫΤϯυ͕ͦΕʹ ͑ΒΕͳ͍Մೳੑ͕͋Δ 46 #cmdevio2016 #La
LambdaόοΫΤϯυͷฒྻੑ • ରࡦ1: εέʔϥϒϧͳόοΫΤϯυΛ͏ • DynamoDB • ରࡦ2: ฒྻΛ੍ޚ͢ΔΈΛೖΕΔ •
FunctionΛىಈ͢ΔFunctionΛઃ͚Δ 47 #cmdevio2016 #La
Lambdaͷඅ༻ 48
Lambdaͷඅ༻ • Lambdaࣗମ֨҆ͩ͠ɺແྉ͕େ͖͍ • AWSτʔλϧͰͷࢼࢉΛ͓͖ͯ͘͠ • ࣮ࡍͷෛՙΛ͔͚ͯྉۚͷ্͕ΓํΛݟΔ 49 #cmdevio2016 #La
Lambdaͷඅ༻ • CloudWatch Logsͷ߹ • FunctionͰඪ४ग़ྗͨ͠༰͕Logsʹ อଘ͞Εͯɺͦ͜Ͱͷ՝͕ۚൃੜ͢Δ • DynamoDBͷ߹ •
ΩϟύγςΟ͑Λ͙߹ଟΊʹઃఆ ͢Δඞཁ͕͋Γɺͦ͜Ͱ՝͕ۚൃੜ͢Δ 50 #cmdevio2016 #La
Agenda • AWS Lambdaͱ࣮ • ࣮ͰͷϢʔεέʔε • LambdaͷTips • ࣮ʹΈࠐΉצॴ
51
ͲͷॲཧΛLambdaʹ͢Δ͔ 52
Lambdaʹ͢Δॲཧ • ϏδωεϩδοΫҎ֎Λସ͢Δ߹ • ϏδωεϩδοΫΛସ͢Δ߹ • ӡ༻ิॿͰ͏߹ • ఘΊΔ߹ 53
#cmdevio2016 #La
ϏδωεϩδοΫҎ֎Λସ͢Δ߹ • αϜωΠϧ࡞ɺϑΥʔϚοτมͳͲ • ΞϓϦέʔγϣϯͷҡ࣋ʹෆՄܽͳػೳ • LambdaԽ͍͢͠ॲཧ • LambdaԽͷԸܙΛड͚͍͢ 54
#cmdevio2016 #La
ϏδωεϩδοΫΛସ͢Δ߹ • ैདྷAPIαʔό͕ߦ͍ͬͯͨॲཧΛସ͢Δ • Ұ൪ߴίετͳ෦͕ղܾ͢Δ • ཁ݅ʹΑ͔ͬͯͬͨ͠Γ͢Δ • CognitoAPIGWΛซ༻͢Δ 55
#cmdevio2016 #La
ӡ༻ิॿͰ͏߹ • CloudFormationͷΧελϜϦιʔεɺcronͷ ସͳͲ • ෆ۩߹࣌ൺֱతΧόʔ͍͢͠ͷͰಋೖ͠ ͍͔͢͠Εͳ͍ 56 #cmdevio2016 #La
ఘΊΔ߹ • ࣮ͰϏδωεͷޭ͕༏ઌ͞ΕΔ͜ͱ͕ଟ͍ • ແཧʹ͓͏ͱ͠ͳ͍ • Lambdaʹͩ͜ΘͬͯϏδωε͕ࣦഊͨ͠Β • ຊస •
ఫୀ͢Δͱ͖ʹLambdaԽͷ༨Λ͢ • LambdaରԠݴޠͰബ͍APIαʔό • όοΫΤϯυʹDynamoDB 57 #cmdevio2016 #La
ͲͷॲཧΛLambdaԽ͢Δ͔ • ӡ༻ิॿ͔ΒॳΊͯɺϏδωεϩδοΫҎ֎ ͷସΛࢦ͢ͷ͕ྑͦ͞͏ • ΞϓϦͷସͱͯ͠͏ͷෑډ͕ߴ͍ • Ϗδωεߟྀ͢Δͱঘྑ͠ 58 #cmdevio2016
#La
ෆ҆ʹඋ͑Δ 59
ෆ҆ʹඋ͑Δ • ࣦഊΛϋϯυϦϯάͰ͖Δͱ͜ΖͰߦ͏ • ӡ༻ٕज़ͷηΧϯμϦ • ࠷ॳLambdaͷସखஈΛߟ͓͑ͯ͘ • ࢹͱτϥϒϧ࣌ͷ෮چखஈΛΕͳ͍ 60
#cmdevio2016 #La
61 44 44 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ classmethod.jp
62 45 45 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ ͋Β͔͡ΊσʔλςʔϒϧΛ࡞͠ VTFS@JE
OBNF TDPSF EBUB XSJUFશৼΓ classmethod.jp
63 46 46 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ ॲཧྔ $47ϑΝΠϧͷߦ
ΛಡΈࠐΈ VTFS@JE OBNF TDPSF EBUB XSJUFશৼΓ classmethod.jp
64 47 47 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF ཧςʔϒϧʹ ૯Λొ͓ͯ͘͠ EBUB XSJUFશৼΓ classmethod.jp
65 48 48 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE σʔλΛ֨ೲͨ͠Β EBUB XSJUFશৼΓ classmethod.jp
66 49 49 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE ΧϯλΛՃࢉ ΞτϛοΫΧϯλ EBUB XSJUFશৼΓ classmethod.jp
67 50 50 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE FGHI σʔλΛ֨ೲͨ͠Β EBUB XSJUFશৼΓ classmethod.jp
68 51 51 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE FGHI ΧϯλΛՃࢉ ΞτϛοΫΧϯλ EBUB XSJUFશৼΓ classmethod.jp
69 52 52 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE FGHI શͯͷޭΛ֬ೝͨ͠Β EBUB XSJUFશৼΓ classmethod.jp
70 53 53 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE FGHI SFBEશৼΓʹ͢Δ EBUB SFBEશৼΓ classmethod.jp
71 55 55 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE ࣦ͠ഊͨ͠Β EBUB XSJUFશৼΓ '"*-&% 9 classmethod.jp
72 56 56 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
VTFS@JE OBNF TDPSF BCDE Ұக͠ͳ͍ͷͰ EBUB XSJUFશৼΓ 㱠 '"*-&% classmethod.jp
73 57 57 ཧςʔϒϧ σʔλςʔϒϧ ςʔϒϧ໊ ૯ ࣮ EBUB
EBUB શͯ࡞Γ͢ VTFS@JE OBNF TDPSF EBUB XSJUFશৼΓ classmethod.jp
มԽʹඋ͑Δ 74
LambdaػೳՃͷྺ࢙ • 2015/04/09 Ұൠެ։ • 2015/05/28 σϓϩΠύοέʔδͷS3ରԠ • 2015/06/15 JavaରԠ
• 2015/07/09 APIGWରԠ • 2015/07/14 DynamoDB StreamsҰൠެ։ • 2015/10/08 Pythonɺόʔδϣϯɺ5ɺcron • 2016/02/11 VPCରԠ 75 http://aws.amazon.com/releasenotes/AWS-Lambda?browse=1 #cmdevio2016 #La
มԽʹඋ͑Δ • LambdaͷػೳՃεϐʔυ͍ • ৽ػೳͰطଘΞϓϦΛLambdaʹ Γग़ͨ͠ΓɺLambdaΛݮΒ͠ଓ͚Δ • ΞϓϦຊମͷςετྑ͍ઃܭΛҡ࣋͢Δ 76 #cmdevio2016
#La
77 Before After #cmdevio2016 #La
·ͱΊ 78
·ͱΊ • ͱΓ࣮͋͑ͣʹऔΓೖΕͯΈΑ͏ • ϏδωεΛՃͤ͞Δ͍ํΛ͠Α͏ • ͜ͷձͰ૬ஊ͠Α͏ • 3FΞʔΩςΫςΟϯά •
3F͓Έ૬ஊࣨ • ࠙ձ 79 #cmdevio2016 #La
80
None