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
68
serverless-design-and-streaming-date-processing-service
yuukigoodman
0
870
alexa-changes-development-process
yuukigoodman
0
1.3k
VUIとAlexaによるちょっと未来の体験の話2
yuukigoodman
0
790
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
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
3
2.4k
re:Invent をおうちで楽しんでみた ~CloudWatch のオブザーバビリティ機能がスゴい!/ Enjoyed AWS re:Invent from Home and CloudWatch Observability Feature is Amazing!
yuj1osm
0
130
バクラクのドキュメント解析技術と実データにおける課題 / layerx-ccc-winter-2024
shimacos
2
1.1k
PHPerのための計算量入門/Complexity101 for PHPer
hanhan1978
5
170
ゼロから創る横断SREチーム 挑戦と進化の軌跡
rvirus0817
2
270
Oracle Cloudの生成AIサービスって実際どこまで使えるの? エンジニア目線で試してみた
minorun365
PRO
4
280
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
170
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
270
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
160
継続的にアウトカムを生み出し ビジネスにつなげる、 戦略と運営に対するタイミーのQUEST(探求)
zigorou
0
590
Google Cloud で始める Cloud Run 〜AWSとの比較と実例デモで解説〜
risatube
PRO
0
110
UI State設計とテスト方針
rmakiyama
2
620
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Producing Creativity
orderedlist
PRO
341
39k
Mobile First: as difficult as doing things right
swwweet
222
9k
Code Review Best Practice
trishagee
65
17k
Unsuck your backbone
ammeep
669
57k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
KATA
mclloyd
29
14k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
Thoughts on Productivity
jonyablonski
67
4.4k
A Modern Web Designer's Workflow
chriscoyier
693
190k
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