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

Perl meets AWS Lambda

moznion
January 26, 2019

Perl meets AWS Lambda

This slide is for YAPC::Tokyo 2019 LT

moznion

January 26, 2019
Tweet

More Decks by moznion

Other Decks in Technology

Transcript

  1. Perl meets AWS Lambda
    YAPC::Tokyo 2019
    @moznion

    View full-size slide

  2. ͜Ε͸ӕʂʂʂʂ

    View full-size slide

  3. AWS Lambdaͷ͓࿩

    View full-size slide

  4. AWS Lambda
    - ୹͍ϫϯγϣοτͷίϯϐϡʔςΟϯά
    ϦιʔεΛఏڙ (࠷ۙ͸5෼͔Β15෼ʹ)
    - αʔόϨεͱ͔ݺ͹ΕͯΔ΍ͭͰ͢ʢࡶʣ

    View full-size slide

  5. ͍ͭʹAWS LambdaʹΞϨ͕དྷ·ͨ͠Ͷ

    View full-size slide

  6. ͍ͭʹAWS LambdaʹΞϨ͕དྷ·ͨ͠Ͷ
    Ruby

    View full-size slide

  7. YAPCͩͧʂʂʂ

    View full-size slide

  8. AWS Lambda Layers

    View full-size slide

  9. AWS Lambda Layers
    - ೚ҙͷϥϯλΠϜΛLambda্Ͱಈ͔ͤΔ࢓૊Έ
    - ϥϯλΠϜͱbootstrapΛzipʹΞʔΧΠϒͯ͠
    Ξοϓϩʔυ
    - See Also https://docs.aws.amazon.com/lambda/latest/
    dg/configuration-layers.html

    View full-size slide

  10. bootstrap
    - LayerͷίΞίϯϙʔωϯτ
    - Lambda FunctionͰLayerΛ༗ޮʹ͢Δͱ

    ͜ͷbootstrap͕ୟ͔ΕΔ

    View full-size slide

  11. 3. Do function
    bootstrap
    bootstrap AWS
    platform
    1. Next Invocation API
    2. Event
    4. Invocation Response/Error

    View full-size slide

  12. γϯϓϧͰ͢Ͷ

    View full-size slide

  13. AWS Lambda Layers
    - ೚ҙͷϥϯλΠϜΛLambda্Ͱಈ͔ͤΔ࢓૊Έ
    - ϥϯλΠϜͱbootstrapΛzipʹΞʔΧΠϒͯ͠
    Ξοϓϩʔυ
    - See Also https://docs.aws.amazon.com/lambda/latest/
    dg/configuration-layers.html

    View full-size slide

  14. AWS Lambda Layers
    - ೚ҙͷϥϯλΠϜΛLambda্Ͱಈ͔ͤΔ࢓૊Έ
    - ϥϯλΠϜͱbootstrapΛzipʹΞʔΧΠϒͯ͠
    Ξοϓϩʔυ
    - See Also https://docs.aws.amazon.com/lambda/latest/
    dg/configuration-layers.html

    View full-size slide

  15. AWS Lambda Layers
    - ೚ҙͷϥϯλΠϜΛLambda্Ͱಈ͔ͤΔ࢓૊Έ
    - ϥϯλΠϜͱbootstrapΛzipʹΞʔΧΠϒͯ͠
    Ξοϓϩʔυ
    - See Also https://docs.aws.amazon.com/lambda/latest/
    dg/configuration-layers.html
    Perl

    View full-size slide

  16. aws-lambda-perl5-layer

    View full-size slide

  17. Perl Lambda Layer
    - Repository: https://github.com/moznion/aws-
    lambda-perl5-layer
    - Blog: aws-lambda-perl5-layer ॻ͍ͨ
    -

    View full-size slide

  18. Perl Lambda Layer
    - Ϟνϕʔγϣϯ
    - ੜ͖͍ͯΔͱ͍Ζ͍Ζ͋Δ
    - ஌త޷ح৺
    - ੜ͖͍ͯΔͱ͍Ζ͍Ζ͋Δ

    View full-size slide

  19. Perl Lambda Layer
    - Layerͷ࡞Γํ
    - bootstrapΛॻ͘
    - LambdaͷϕʔεDockerίϯςφʹperlΛΠϯετʔϧ
    - Πϯετʔϧͨ͠PerlϥϯλΠϜͱbootstrapΛzipʹݻΊΔ
    - Ξοϓϩʔυʂʂ

    View full-size slide

  20. Perl Lambda Layer
    - ಛ௃
    - carton friendly
    - ϏϧυࡁΈLayerఏڙ͋Γ
    - arn:aws:lambda:${REGION}:652718333417:layer:perl-5_26-layer:1
    - arn:aws:lambda:${REGION}:652718333417:layer:perl-5_28-layer:1
    - શAWSϦʔδϣϯαϙʔτ

    View full-size slide

  21. Perl Lambda Layer
    - ap-northeast-1
    - ap-northeast-2
    - ap-south-1
    - ap-southeast-1
    - ap-southeast-2
    - ca-central-1
    - eu-central-1
    - eu-west-1
    - eu-west-2
    - eu-west-3
    - sa-east-1
    - us-east-1
    - us-east-2
    - us-west-1
    - us-west-2

    View full-size slide

  22. Perl Lambda Layer
    - FunctionͷσϓϩΠํ๏
    - (dependencyΛlocalҎԼʹvendoring͢Δ)
    - σΟϨΫτϦશମΛzipʹ·ͱΊΔ

    View full-size slide

  23. ؆୯Ͱ͢Ͷʁ

    View full-size slide

  24. ͍΍ʔΊΜͲ͘Ͷʁ

    View full-size slide

  25. App::Perlambda

    View full-size slide

  26. App::Perlambda
    - aws-lambda-perl5-layer޲͚ͷϚωδϝϯτ

    CLIπʔϧ
    - dist, create, updateʹରԠ
    - https://github.com/moznion/p5-App-Perlambda

    View full-size slide

  27. ·ͱΊ
    - Ruby͕AWS LambdaʹରԠ͠·ͨ͠
    - AWS LambdaʹLayers͕΍͖ͬͯ·ͨ͠
    - Perl͕LayerͷྗͰAWS LambdaʹରԠ͠·ͨ͠
    - App::Perlambdaͱ͍͏ˢͷϚωδϝϯτπʔϧ
    Λॻ͖·ͨ͠

    View full-size slide

  28. ॴײ
    - ࣮ࡍLambdaॻ͘ͳΒඇಉظॲཧ͠΍͍͢ݴޠΛ

    બΜͩ΄͏͕͍͍ͱࢥ͏……
    - go
    - node
    - ͳͲ
    - ͳ͓ fork(2) ͸Ͳ͏΍Βಈ͘……

    View full-size slide

  29. ͦͷଞ
    - ศརͦ͏ͳͷ͕ग़ͨ
    - https://github.com/awslabs/aws-lambda-
    container-image-converter

    View full-size slide