Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

AWS における サーバーレスの基礎からチューニングまで

2,765 views

Published on

Serverless Meetup Osaka #3
2017/8/25

Published in: Technology
  • Be the first to comment

AWS における サーバーレスの基礎からチューニングまで

  1. 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. /MB N AFC >FR IDFS BPBN K#K# BKB UKI >HIMI U /A> > LUTI NS /RDHITFDT 2017. 8. 25 AWS iW r j m
  2. 2. a a /A> IKF /MB N 1 NNFDT j
  3. 3. 2 NBM 20 x a a INFSIS v
  4. 4. v # /A> jo a a # a a (# a a a )#
  5. 5. & iW r
  6. 6. a k? a g i p n a ” t v p
  7. 7. a a a a a a a
  8. 8. l uz a g t z a ..
  9. 9. a z AWS Lambda Amazon DynamoDB Amazon SNS Amazon API Gateway Amazon SQS Amazon Kinesis Amazon S3 Orchestration and State Management API Proxy Messaging and Queues Analytics Monitoring and Debugging Compute Storage Database AWS X-RayAWS Step Functions Edge Compute AWS Greengrass Lambda@Edge
  10. 10. a h v k” i a v a a z o a r”
  11. 11. Chatbots • • Amazon Echo Alexa Skill a a Web a • Web • Web • Flask Express z a Backends • a • • IoT </></> Media & Log Processing • a • a a Big Data • MapReduce •
  12. 12. Going Serverless with AWS AWS Summit Tokyo 2017 https://d0.awsstatic.com/events/jp/2017/summit/slide/D2T1-2.pdf https://www.youtube.com/watch?v=QaVloD5O5t8
  13. 13. T j g
  14. 14. 1HBLIDF 3RBMFW RK >/: >FR FRLFSS /PPLIDBTI N : FL
  15. 15. HL HC II C FE F C • a r z/A> 1L U 3 RMBTI N • a a • ”>/: a t a • BPBDHF # • a l>/:” t ” v p
  16. 16. SAM j i U j $ aws cloudformation pakage • zip file • Amazon S3 • S3 URI CodeUri $ aws cloudformation deploy • CloudFormation CreateChangeSet API • CloudFormation ExecuteChangeset API
  17. 17. Severless Tempalete SAM templete yaml Cloudformation yaml package xxx S3 upload Serverless template
  18. 18. j jv AWS Lambda Amazon DynamoDB Key: test(String) put role
  19. 19. r https://github.com/awslabs/serverless-application-model/tree/master/examples/2016-10-31
  20. 20. 1F C
  21. 21. CI/CD AWS Summit Tokyo 2017 https://d0.awsstatic.com/events/jp/2017/summit/devday/D4T7-6.pdf https://www.youtube.com/watch?v=FZfD1dTWlLA
  22. 22. github/awslabs
  23. 23. https://github.com/awslabs
  24. 24. https://github.com/awslabs AWS OSS GitHub • 2017 6 300 • github/aws Fixed
  25. 25. awslabs https://github.com/awslabs/git-secrets • AWS Access Key ~/.aws/credentials https://github.com/awslabs/s2n • TLS/SSL https://github.com/awslabs/aws-{platform}-sample • • swift, android, machinelearning, serverless… https://github.com/awslabs/chalice • Python Serverless
  26. 26. Express.js Java Container awslabs MI I HL HC II H II MI I HL HC II A L FE E H
  27. 27. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. - H II AI O & D C t aenr a a $ git clone https://github.com/awslabs/aws-serverless-express $ cd aws-serverless-express/example $ ls -1 README.md api-gateway-event.json app.js app.local.js cloudformation.yaml lambda.jspackage.json sam-logo.png scripts simple-proxy-api.yaml vanilla-server.js views
  28. 28. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. $ npm install && npm run start (snip) listening on http://localhost:3000 - H II AI O & D C t aenr a http://localhost:3000 => e a tzg F#JS , ) l
  29. 29. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. - H II AI O & D C t aenr /A> $ npm run config -- --account-id="<accountId>" --bucket-name="<bucketName>" [--region="<region>" --function-name="<functionName>"] # region, function-name ” v # us-east-1, AwsServerlessExpressFunction $ npm run setup AIN WS npm run win-setup (snip) Successfully created/updated stack – AwsServerlessExpressStack # Tips: # "ZIP does not support timestamps before 1980" al z m # find . -mtime +1200 -exec touch {} ; h m
  30. 30. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. - H II AI O & D C t aenr r z = ” t n CF .FHD FE FD S MI HL HC II- H II S 3 I S HC t
  31. 31. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. - H II AI O & D C t aenr $ curl https://avcitqw9p6.execute-api.us-east-1.amazonaws.com/prod/users -H 'accept: application/json' [{"id":1,"name":"Joe"},{"id":2,"name":"Jane"}]
  32. 32. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. - H II AI O & D C t aenr GET https://(snip)/sam x ux i 1i $ curl -Iso /dev/null https://avcitqw9p6.execute-api.us-east-1.amazonaws.com/prod -w '%{content_type}' text/html; charset=utf-8
  33. 33. AWS CodeStar https://aws.amazon.com/jp/codestar/ Quickly develop, build, and deploy applications on AWS AWS CodeStar
  34. 34. F H FE HL HC II H II g S - H II AI I HL 1 D H EE E I HL HC II t
  35. 35. H E p F H FE HL HC II
  36. 36. t S H 4HFA t cg F H FE HL HC II
  37. 37. srjk MIC I j x i msr gk j F H FE HL HC II
  38. 38. FFC t ,- i F H tx S FDD 4 I sl x sr F H FE HL HC II
  39. 39. AWS CodePipeline AWS CodeCommit AWS CodeBuild Amazon S3 AWS CloudFormationDeveloper Amazon API Gateway AWS Lambda CodeStar CI/CD F H FE HL HC II
  40. 40. Web AWS Summit Tokyo 2017 https://d0.awsstatic.com/events/jp/2017/summit/devday/D4T7-3.pdf https://www.youtube.com/watch?v=aiH8Z7MGGL0
  41. 41. ( j i 1 D
  42. 42. hr a a a a a
  43. 43. j Lambda t r g y • p a m p g y
  44. 44. hr a a a a a
  45. 45. w • t g l a a • t CPU • a • ” tl l ” vp l y “ w l l p tw t t l g l
  46. 46. hr a a a a a
  47. 47. Lambda u i eUr g 1. cENI d 2. 3. a a 4. a 5. 6. / • VPC” v o • 10 b30 kk • Duration g
  48. 48. Lambda u i eUr g 1. cENI d 2. 3. a a 4. a 5. 6. / • r z • S3k a ZIP • Duration g
  49. 49. Lambda u i eUr g 1. cENI d 2. 3. a a 4. a 5. 6. / • • a a p r • Duration g
  50. 50. Lambda u i eUr g 1. cENI d 2. 3. a a 4. a 5. 6. / • a tz / • g Duration pp
  51. 51. Lambda u i eUr g 1. cENI d 2. 3. a a 4. a 5. 6. / v ” v l a a
  52. 52. Lambda u i eUr g 1. cENI d 2. 3. a a 4. a 5. 6. / u l r v p t c a a d
  53. 53. r h l g • y y 1 l g • v m l z • a ” tz • a ” v y m g l g a a “ t g
  54. 54. gj U a a ”0 v p tg • y n n g g • a a g • y y p j m p g a a ” zn m g y AWS Lambda g p ” i a a ” nv tk g
  55. 55. t r a a ” v • a a ” vp n ” i • i AWS Lambda w JVM g • z t “hl g
  56. 56. t r a ” rnv • l mn a a a a j Zip lkk • a v • ” v • a g • Java tl • Java ProGuard a a ” v gh •
  57. 57. t r VPC g t g • h VPC a ht v l m o • VPC ” t g a a 10 k 30 l a a ” m g o g • VPC a l v • RDBMS a l DynamoDB Streams AWS Lambda”
  58. 58. t r Java • POJO n a ” h • v JSON a lkk a t JSON ” z v p – https://github.com/FasterXML/jackson-jr – http://docs.aws.amazon.com/lambda/latest/dg/java-handler-io-type- stream.html • ” a v h Java8 ” t g clambda d
  59. 59. t r ” n a a l n a ” h import boto3 client = None def my_handler(event, context): global client if not client: client = boto3.client("s3") # process
  60. 60. hr a a a a a
  61. 61. v j Invokev kk l • t r z ”t a r g • t r z ” iz al r t h • r m o Invokev l a • y vk • Amazon API Gateway x PUT ”AWS Lambda v n a t t Amazon SQS Amazon Kinesis v v
  62. 62. API Gatewayj / 4BTFWB /A> BMC B /A> a 5 > Lambda ” vp
  63. 63. v j Think Parallel • AWS Lambda kv gk ” hk 1 z ” rnt kx h a v • 1 Invoke a rx n a Lambda ” Invokev • Lambda l kk nn
  64. 64. hr a a a a a
  65. 65. S S (S )S S RF SFD (S F FD , r g
  66. 66. - j a a a a (
  67. 67. Limit IncreaseidUe 1000 l g gm k ” t g • Throttler g k hk ” • Throttler g k • a a ” a SA q ” Limit Increaset l t gp • a a ” tz ” tz t g g • y y lkk g t g
  68. 68. AWS Lambda RDBMS U b AWS Lambda + RDBMSl a • • AWS Lambda a a z a tg • AWS Lambdal a v l r z k DB l p i g a l • VPC a a • VPC a a l v a a 10 ” v • Amazon DynamoDB” h • k RDBMS l DynamoDB Streams AWS Lambda” t v
  69. 69. m P v jv – g AWS Summit Tokyo 2017 https://d0.awsstatic.com/events/jp/2017/summit/devday/D4T7-2.pdf https://www.youtube.com/watch?v=-PEADfcGvJU
  70. 70. ) mgo
  71. 71. mgo # /A> jo a a r s a ” t a ” i gn # a a GITHUC BWSLBCS /A> >/: /A> 1 F>TBR (# a a a a a a a a
  72. 72. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambdaj eUm 2017 6 9 3,240 c d Amazon http://amzn.asia/ew2WWPm

×