$30 off During Our Annual Pro Sale. View Details »

理解して導入するWebフレームワーク ~解決すべき課題に着目する~ / Understanding and implementing web frameworks ~focusing on the problems to be solved~

shiro seike
PRO
September 23, 2023

理解して導入するWebフレームワーク ~解決すべき課題に着目する~ / Understanding and implementing web frameworks ~focusing on the problems to be solved~

ServerlessDays Tokyo 2023
https://tokyo.serverlessdays.io/

shiro seike
PRO

September 23, 2023
Tweet

More Decks by shiro seike

Other Decks in Programming

Transcript

  1. Web


    ~ ~
    ServerlessDays Tokyo
    2
    023
    2
    0
    23
    .
    9
    .
    23



    @seike
    4
    60
    1

    View Slide

  2. @seike
    46
    0
    -


    - @seike
    46
    0

    - AWS Community Builder Serverless


    - Fusic


    - /


    - /


    -


    - ServerlessDays Tokyo
    2
    022
    Virtual


    -


    - ServerlessDays Fukuoka
    2
    019
    Co-Chairs


    - ServerlessDays Tokyo
    2
    019
    ,
    2
    022
    ,
    2023
    2

    View Slide

  3. Agenda
    1
    .AWS Lambda


    2
    .Web AWS Lambda


    3
    .


    4
    .


    5
    .
    3

    View Slide

  4. 01
    AWS Lambda

    View Slide

  5. AWS Lambda


    Lambda









    Lambda




    VPC


    ⾒ Lambda VPC


    VPC Lambda




    Lambda SecretManager




    AWS CloudWatch Logs CloudWatch Metrics Lambda
    5

    View Slide

  6. 02
    Web AWS Lambda

    View Slide

  7. Laravel
    PHP Web


    AWS ⾒


    S
    3
    DynamoDB


    Eloquent ORM


    Laravel




    Laravel API




    Passport Sanctum API


    API


    Laravel API JSON





    Laravel


    7

    View Slide

  8. Laravel
    8

    View Slide

  9. Bref
    Bref PHP OSS


    AWS Lambda PHP


    AWS Lambda PHP


    PHP

    PHP


    Bref PHP


    PHP


    AWS Lambda Developer Community




    Laravel Symfony PHP




    CLI
    9

    View Slide



  10. Developer Community


    AWS Lambda


    PHP PHP

    PHPer



    Bref


    Serverless Framework




    10
    service: app-php-serverless


    provider:


    name: aws


    region: ap-northeast-
    1


    plugins:


    - ./vendor/bref/bref


    functions:


    api:


    handler: index.php


    description: ''


    runtime: php-
    8
    2
    -fpm


    timeout:
    28


    events:


    - httpApi: '*'


    # Exclude files from deployment


    package:


    patterns:


    - '!node_modules/**'


    - '!tests/**'
    $ composer require bref/bref


    $ vendor/bin/bref init


    $ serverless deploy

    View Slide

  11. 11
    Bref AWS Lambda API Gateway


    Bref API Gateway AWS Lambda


    Bref Laravel Bridge Laravel


    Bref Lambda

    View Slide

  12. Laravel Bref
    12
    Laravel Bref PHP

    AWS Lambda PHP


    AWS Lambda




    AWS Lambda Laravel


    PHPer


    View Slide

  13. View Slide

  14. AWS Lambda
    14

    Lambda









    Lambda




    VPC


    ⾒ Lambda VPC


    VPC Lambda




    Lambda SecretManager




    AWS CloudWatch Logs CloudWatch Metrics Lambda

    View Slide

  15. Lambda
    Amazon Web Services Operating Lambda: Part
    3



    -Lambda


    -


    -


    -


    -


    -


    - Laravel


    - Laravel
    15
    URL:https://aws.amazon.com/jp/blogs/news/compute-operating-lambda-anti-patterns-in-event-driven-architectures-part-
    3
    /


    Operating Lambda: Part
    3

    View Slide

  16. View Slide

  17. Point


    View Slide

  18. 03 


    View Slide

  19. PHP Ruby AWS


    AWS Lambda


    Web Web


    - PHP Laravel CakePHP


    - Ruby Ruby on Rails


    19

    View Slide

  20. Python

    API


    EC
    2
    API


    API Gateway -> Lambda -> S
    3
    Json EC
    2
    cron
    20
    Python


    Python -> Go

    View Slide



  21. AWS Amplify Web

    ECR AWS Batch Step Functions


    AWS Amplify
    21

    View Slide




  22. Ruby



    AWS Lambda
    22

    View Slide

  23. Point


    View Slide



  24. Laravel





    Laravel








    Laravel Web


    24

    View Slide

  25. PHP AWS Lambda
    PHP 2018


    PHP Conference
    201
    9

    AWS Lambda PHP
    25

    View Slide

  26. AWS Dev Day
    2 022
    AWS Dev Day
    2 02 2

    Amazon S
    3
    Select
    で バ

    https://speakerdeck.com/seike
    460
    /serverless-high-load-site-realized-with-amazon-s
    3
    -select
    26

    View Slide

  27. AWS Lambda x Bref x Laravel
    27


    - AWS Lambda


    - AWS S
    3
    Select


    - S
    3
    JSON SQL



    PHP AWS Lambda




    Laravel

    View Slide

  28. Web AWS Lambda


    AWS Lambda








    28

    View Slide

  29. Point
    AWS Lambda


    View Slide





  30. 30

    View Slide




  31. 31

    View Slide

  32. AWS ⾒





    AWS Lambda


    32

    View Slide









  33. 
 

    33

    View Slide

  34. Laravel
    34
    Web




    AWS Lambda






    Laravel

    View Slide

  35. Point

    View Slide

  36. deploy PHP
    36
    Deploying bref-natural to stage dev (ap-northeast-1)
    ✔ Service deployed to stack bref-natural-dev (30s)
    endpoint: ANY - https://xxxxxxxxxx.execute-api.ap-northeast-1.amazonaws.com
    functions:
    api: bref-natural-dev-api (260 kB)
    Want a better experience than the AWS console? Try out https://dashboard.bref.sh
    30


    260kB

    View Slide

  37. deploy Laravel
    37
    Deploying bref-laravel to stage dev (ap-northeast-1)
    ✔ Service deployed to stack bref-laravel-dev (52s)
    endpoint: ANY - https://yyyyyyyyyy.execute-api.ap-northeast-1.amazonaws.com
    functions:
    web: bref-laravel-dev-web (32 MB)
    artisan: bref-laravel-dev-artisan (32 MB)
    Want a better experience than the AWS console? Try out https://dashboard.bref.sh
    30 -> 52


    260kB ->
    3 2
    M


    View Slide

  38. [#/sec] PHP
    38
    $ ab -n 20000 -c 10 https://xxxxxxxxxx.execute-api.ap-northeast-1.amazonaws.com/
    ~
    Requests per second: 303.30 [#/sec] (mean)
    Requests per second: 349.55 [#/sec] (mean)
    Requests per second: 351.93 [#/sec] (mean)
    ~
    EC
    2
    Apache Bench


    351
    .
    93
    [#/sec]
    3

    View Slide

  39. [#/sec] Laravel
    39
    $ ab -n 20000 -c 10 https://yyyyyyyyyy.execute-api.ap-northeast-1.amazonaws.com/
    ~
    Requests per second: 240.62 [#/sec] (mean)
    Requests per second: 244.52 [#/sec] (mean)
    Requests per second: 262.52 [#/sec] (mean)
    ~
    EC
    2
    Apache Bench


    351
    .
    93
    [#/sec] ->
    262
    .
    52
    [#/sec]



    3

    View Slide








  40. 40

    View Slide

  41. Point
    Monolith First Serverless Development

    View Slide

  42. Monolith First Serverless Development
    42
    URL : https://speakerdeck.com/_kensh/monolith-first-serverless-development?slide=
    55
    @_kensh


    Monolith First Serverless Development

    View Slide





  43. Role




    APIGateway ⾒
    43
    functions:


    web:


    handler: public/index.php


    runtime: php-
    82
    -fpm


    timeout:
    28

    events:


    - httpApi: '*'


    admin-web:


    handler: public/index.php


    runtime: php-
    82
    -fpm


    timeout:
    28

    role: api-admin-role


    events:


    - httpApi:


    method: '*'


    path: /admin
    $ serverless deploy function --function admin-web


    Deploying function admin-web to stage dev (ap-northeast-
    1
    )


    ✔ Function code deployed (
    42
    s)


    Function configuration did not change, and the update was skipped. If you made changes to the service configuration and expected them to be
    deployed, it most likely means that they can only be applied with a full service deployment. (
    42
    s)

    View Slide

  44. 04

    View Slide



  45. :


    : Laravel




    :


    :


    : AWS
    45

    View Slide



  46. :


    : Laravel




    :


    :


    : AWS
    46

    View Slide

  47. AWS Lambda x Bref x Laravel
    47
    Web


    AWS Lambda PHP ⾒



    0


    Laravel


    Laravel



    Laravel
    AWS ⾒

    View Slide



  48. :


    : Laravel




    :


    :


    : AWS
    48

    View Slide






  49. 49

    View Slide

  50. 50
    Point
    1
    Point
    2
    Monolith First Serverless Development (@_kensh) or
    Point
    3
    Point
    4

    View Slide

  51. Thank You
    We are Hiring !


    https://recruit.fusic.co.jp/

    View Slide