Upgrade to Pro — share decks privately, control downloads, hide ads and more …

全部教えます!サーバレスアプリのアンチパターンとチューニング

 全部教えます!サーバレスアプリのアンチパターンとチューニング

AWS Summit Tokyo 2017のServerless Evolution Dayでの講演資料です。

Keisuke69

June 08, 2017
Tweet

More Decks by Keisuke69

Other Decks in Technology

Transcript

  1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Keisuke Nishitani (@Keisuke69), Specialist SA, Serverless
    Jun 2, 2017
    d i t e t
    ct

    View Slide

  2. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Who am I
    Specialist Solutions Architect, Serverless
    Amazon Web Service Japan K.K
    @Keisuke69 Keisuke69 Keisuke69 Keisuke69
    Keisuke69x

    View Slide

  3. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    u nt
    AWS Lambda s q
    e W
    S

    View Slide

  4. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Lambdah t ntK

    View Slide

  5. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

    View Slide

  6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

    View Slide

  7. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    is k
    Lambda
    ” c
    • H X q
    H qc ww
    qw

    View Slide

  8. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

    View Slide

  9. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    t t
    • q W q
    • CPU
    • q
    • W WH W
    H qc m a W
    W
    a H W W

    View Slide

  10. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

    View Slide

  11. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Lambdah t nt
    1. OENI P
    2.
    3. ”
    4. ”
    5. I
    6. /
    • VPC
    • 10 30
    • Duration q w

    View Slide

  12. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Lambdah t nt
    1. OENI P
    2.
    3. ”
    4. ”
    5. I
    6. /
    • e
    • S3 “ ZIP
    • Duration q w

    View Slide

  13. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Lambdah t nt
    1. OENI P
    2.
    3. ”
    4. ”
    5. I
    6. /


    • Duration q w

    View Slide

  14. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Lambdah t nt
    1. OENI P
    2.
    3. ”
    4. ”
    5. I
    6. /
    • e /
    • Duration q

    View Slide

  15. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Lambdah t nt
    1. OENI P
    2.
    3. ”
    4. ”
    5. I
    6. /
    W

    View Slide

  16. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Lambdah t nt
    1. OENI P
    2.
    3. ”
    4. ”
    5. I
    6. /

    View Slide

  17. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Lambdah t nt
    1. OENI P
    2.
    3. ”
    4. ”
    5. I
    6. /
    W

    View Slide

  18. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Lambdah t nt
    1. OENI P
    2.
    3. ”
    4. ”
    5. I
    6. /
    W
    O“ P

    View Slide

  19. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    b a
    S H W
    • c c 1 W
    • X W e
    • H e
    • H c w q X

    View Slide

  20. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    b a
    S H W
    • c c 1 W
    • X W e
    • H e
    • H c w q X
    W rH
    q m

    View Slide

  21. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    b a
    0 q
    • c
    • L
    • c c H q X q
    w e X rHc
    AWS Lambdaq q
    wT H

    View Slide

  22. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    b a

    View Slide

  23. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    b a

    T
    • TrAWS Lambda aHJVM q
    • e H w SW

    View Slide

  24. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    b a

    • W X
    sZip W
    • q

    • ” q y
    • Javaq W
    • Java ProGuard m
    S
    • q

    View Slide

  25. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    b a
    VPCq
    • S qVPC mS W
    X
    • VPC 10
    30
    W X
    q
    • VPC W r
    • RDBMS W rDynamoDB Streams AWS
    Lambda

    View Slide

  26. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    b a
    Java q
    • POJO q S
    • JSON q
    W H JSON
    e
    – https://github.com/FasterXML/jackson-jr
    – http://docs.aws.amazon.com/lambda/latest/dg/java-handler-io-type-
    stream.html
    • S Java8
    OlambdaH H mP

    View Slide

  27. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    b a
    W
    S
    import boto3
    client = None
    def my_handler(event, context):
    global client
    if not client:
    client = boto3.client("s3")
    # process

    View Slide

  28. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

    View Slide

  29. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Invoke w W
    • s H e H
    • s H e Te W
    wS
    • q
    X Invoke W q
    • c H
    • Amazon API Gateway x b HPUT AWS
    Lambda q H
    Amazon SQSHAmazon Kinesis m

    View Slide

  30. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    API Gateway is
    “ 41 / = E
    5 2 :
    5
    0 4 5

    View Slide

  31. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    API Gateway is
    “ 41 / = E
    5 2 :
    5
    0 4 5
    Lambda
    s

    View Slide

  32. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Think Parallel
    • AWS Lambda q S
    1 e b
    S
    • 1 Invoke b q H Lambda
    Invoke
    • Lambda W H

    View Slide

  33. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

    View Slide

  34. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    A A A A (A
    )
    = A=
    ) A = =
    F G

    View Slide

  35. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    - a k

    View Slide

  36. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Limit Increase
    q1000H W X
    • Throttle mS
    • Throttle mq
    • m qH HSA
    Limit Increase W
    • H e e
    • c c W H q

    View Slide

  37. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    t e t

    View Slide

  38. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    AWS LambdaFRDBMS
    AWS Lambda + RDBMSW

    • AWS Lambdaq eyH
    q
    • AWS LambdaW H w W
    e H DBt W H T
    W
    • VPC
    • VPC W H 10
    • Amazon DynamoDB S
    • RDBMS W qDynamoDB Streams
    AWS Lambda

    View Slide

  39. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    IP N
    Amazon API Gateway AWS Lambda API
    IP e
    m X
    • IP S q
    W
    AWS Lambda qVPC NAT S S
    q W…
    • VPC
    • NAT Hc H H
    W

    View Slide

  40. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    d
    r W H W10
    1
    • q W q
    • W eyH
    q W WH W mqc
    • H T W
    • S H I W W
    X
    S X q w S

    View Slide

  41. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Serverless != Monitorless
    q
    • H
    • CloudWatch OErrors, ThrottlesP
    • CloudWatch
    • CloudWatch Logst

    View Slide

  42. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

    • Dead Letter Queue O P
    q W
    • AWS Lambda q 1 1
    q
    • Lambda W2
    Ww
    • Amazon DynamoDB m
    S

    View Slide

  43. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Wrap-up
    AWS Lambda W





    c d S
    q X w S

    View Slide

  44. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    AWS Lambda u
    2017 6 9
    3,240 O P
    Amazon
    http://amzn.asia/ew2WWPm
    AWS Summit Expo H
    • w
    • “ Xw

    View Slide

  45. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
    Thank You!

    View Slide