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

AWS Lambda PHPのProduction利用を続ける僕がAWS App Runnerの可能性を探る

AWS Lambda PHPのProduction利用を続ける僕がAWS App Runnerの可能性を探る

shiro seike
PRO

March 23, 2023
Tweet

More Decks by shiro seike

Other Decks in Technology

Transcript

  1. AWS Lambda PHP Production


    AWS App Runner
    PHPerKaigi
    2
    0 23
    2
    0
    23
    .
    3
    .
    25



    @seike
    4
    60
    1

    View Slide

  2. @seike
    460
    -


    - @seike
    46
    0

    - Fusic


    - /


    - / /


    -


    - PHP ( )


    - PHPerKaigi(
    201
    9 2
    0
    2 3
    )


    - AWS


    -


    - 2023 6 24

    PHP 2023

    2

    View Slide

  3. Agenda
    1
    . AWS Lambda PHP


    2
    . AWS App Runner


    3
    . AWS App Runner PHP
    8
    .
    1

    4
    . AWS Lambda PHP AWS App Runner


    5
    .
    3

    View Slide

  4. 01
    AWS Lambda PHP

    View Slide

  5. AWS Lambda
    -


    AWS

    -




    -


    5

    View Slide

  6. AWS Lambda PHP
    PHP AWS



    PHP
    6
    AWS Lambda PHP OSS Project Bref

    PHP
    Laravel Symfony

    View Slide

  7. Amazon S
    3
    Select
    で バ
    7

    View Slide

  8. 02
    AWS App Runner

    View Slide

  9. AWS App Runner



    VPC ELB Fargate CodeBuild CD

    App Runnner








    AWS App Runner






    Docker Docker ECR

    Python Node.js Ruby Java .NET


    9

    View Slide

  10. AWS App Runner PHP
    8
    .
    1
    PHP
    8
    .
    1
    AWS App Runner PHP
    10

    View Slide



  11. - Amazon VPC


    - Elastic Load Balancing


    - AWS App Runner


    - CodeBuild GitHub


    - Amazon CloudWatch Logs


    AWS VPC


    https

    ELB <-> App Runner



    11

    View Slide

  12. Route
    5 3
    https://XxxxxxxxxX.ap-northeast-
    1
    .awsapprunner.com





    SSL
    12

    View Slide

  13. RDS Cache AWS Secrets Manager
    Web

    Cron



    RDB VPC




    Amazon RDS


    Cache Redis

    Amazon ElastiCache


    API


    AWS Secrets Manager
    13

    View Slide

  14. AWS WAF

    Public

    14
    AWS WAF

    IP


    http->https

    View Slide

  15. GitHub







    15

    View Slide

  16. 03
    AWS App Runner PHP
    8
    .
    1

    View Slide

  17. ->
    Example




    17

    command: php -S
    0
    .
    0
    .
    0
    .
    0
    :
    8 0 80
    -t .


    Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y



    View Slide

  18. 18
    Nextat


    (@n_
    12
    15
    )


    AWS App Runner PHP


    Apache + PHP-FPM


    https://nextat.co.jp/staff/archives/
    3
    03

    View Slide



  19. 335
    83
    8 599 203
    .dkr.ecr.ap-northeast-
    1
    .amazonaws.com/awsfusionruntime-php
    81
    :
    8
    .
    1
    .
    1 4 





    19

    View Slide

  20. command
    っcommand




    nginx httpd
    20

    View Slide

  21. command
    っpre-build


    っbuild


    っpost-build


    build command


    $ for x in ${PATH//:/ }; do ls -
    1
    $x; done | sort | uniq


    apache
    2
    httpd nginx


    yum command Install
    21

    View Slide

  22. 22

    View Slide

  23. 3 17 1
    23
    🎉

    View Slide

  24. 24
    nginx(https) php-fpm


    Startup.sh

    wait


    DocumentRoot /app/public index.php


    Framework


    Laravel

    View Slide

  25. 25
    .env



    PHP


    URL Git Clone

    URL


    https://github.com/seike
    4
    60
    /laravel-lambda-app-runner

    View Slide

  26. supervisord
    26 


    Example


    Supervisord

    Supervisord



    build

    View Slide

  27. 27
    ΧελϚΠζͷՄೳੑ͸͋Γͦ͏
    ■php-fpm

    include=/etc/php-fpm.d/*.conf
    ■nginx

    include /etc/nginx/default.d/*.conf
    ■httpd
    IncludeOptional conf.d/*.conf
    →/etc/httpd/conf.d

    View Slide

  28. 04
    AWS Lambda PHP


    X

    AWS App Runner PHP

    View Slide

  29. Pickup

    View Slide

  30. 30
    t3.medium

    View Slide

  31. AWS Lambda
    1
    0 0
    Client
    10 0
    Request
    31

    100
    Client
    1 00
    Request


    Requests per second:
    2
    6
    .
    89
    [#/sec] (mean)








    This is ApacheBench, Version
    2
    .
    3
    <$Revision:
    1
    90
    3 6
    18
    $>


    Copyright
    1996
    Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/


    Licensed to The Apache Software Foundation, http://www.apache.org/


    Benchmarking XxxxxxxxX.execute-api.ap-northeast-
    1
    .amazonaws.com (be patient).....done


    Server Software:


    Server Hostname: XxxxxxxxX.execute-api.ap-northeast-
    1
    .amazonaws.com


    Server Port:
    44 3


    SSL/TLS Protocol: TLSv
    1
    .
    2
    ,ECDHE-RSA-AES
    1
    2 8
    -GCM-SHA
    2
    56
    ,
    20
    4 8
    ,
    12
    8

    Server Temp Key: ECDH P-
    25
    6 2
    56
    bits


    TLS Server Name: XxxxxxxxX.execute-api.ap-northeast-
    1
    .amazonaws.com


    Document Path: /


    Document Length:
    2
    7 49 6
    bytes


    Concurrency Level:
    10 0


    Time taken for tests:
    3
    .
    7
    1 8
    seconds


    Complete requests:
    1 0
    0

    Failed requests:
    0

    Total transferred:
    29 51
    0 00
    bytes


    HTML transferred:
    274 9
    6 0
    0
    bytes


    Requests per second:
    2 6
    .
    89
    [#/sec] (mean)


    Time per request:
    371 8
    .
    1
    86
    [ms] (mean)


    Time per request:
    37
    .
    18 2
    [ms] (mean, across all concurrent requests)


    Transfer rate:
    77 5
    .
    07
    [Kbytes/sec] received


    Connection Times (ms)


    min mean[+/-sd] median max


    Connect:
    6 1 6
    9 2 4
    .
    5 163 19
    4

    Processing:
    36 1
    2 60 5 12
    .
    0 14
    63 1999


    Waiting:
    36 1
    2 5
    7 51 0
    .
    9 1
    462 1 8
    03


    Total:
    195 142 9 51 6
    .
    0 1640 20
    05


    Percentage of the requests served within a certain time (ms)


    5
    0
    %
    1640

    6
    6
    %
    1658

    7
    5
    %
    1680

    8
    0
    %
    1695

    9
    0
    %
    1723

    9
    5
    %
    1744

    9
    8
    %
    1907

    9
    9
    %
    2005

    1
    00
    %
    2
    0
    05
    (longest request)

    View Slide

  32. AWS App Runner
    1 0
    0
    Client
    10
    0
    Request
    32
    This is ApacheBench, Version
    2
    .
    3
    <$Revision:
    1
    90
    3 6
    18
    $>


    Copyright
    1996
    Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/


    Licensed to The Apache Software Foundation, http://www.apache.org/


    Benchmarking YyyyyyyyyY.ap-northeast-
    1
    .awsapprunner.com (be patient).....done


    Server Software: envoy


    Server Hostname: YyyyyyyyyY.ap-northeast-
    1
    .awsapprunner.com


    Server Port:
    44 3


    SSL/TLS Protocol: TLSv
    1
    .
    2
    ,ECDHE-RSA-AES
    1
    2 8
    -GCM-SHA
    2
    56
    ,
    20
    4 8
    ,
    12
    8

    Server Temp Key: ECDH P-
    25
    6 2
    56
    bits


    TLS Server Name: YyyyyyyyyY.ap-northeast-
    1
    .awsapprunner.com


    Document Path: /


    Document Length:
    2
    7 49 6
    bytes


    Concurrency Level:
    10 0


    Time taken for tests:
    2
    .
    5
    6 7
    seconds


    Complete requests:
    1 0
    0

    Failed requests:
    0

    Total transferred:
    28 62
    1 36
    bytes


    HTML transferred:
    274 9
    6 0
    0
    bytes


    Requests per second:
    3 8
    .
    96
    [#/sec] (mean)


    Time per request:
    256 7
    .
    0
    16
    [ms] (mean)


    Time per request:
    25
    .
    67 0
    [ms] (mean, across all concurrent requests)


    Transfer rate:
    10 88
    .
    83
    [Kbytes/sec] received


    Connection Times (ms)


    min mean[+/-sd] median max


    Connect:
    2 4 1
    9 9 35
    .
    4 20
    6 2
    19


    Processing:
    1012 18 8
    3 3
    35
    .
    4 20
    0 5 230
    3

    Waiting:
    16 78 1 372
    .
    9 902 130
    5

    Total:
    1
    047 2 0
    82 35 6
    .
    8 2210 2 5
    14


    Percentage of the requests served within a certain time (ms)


    5
    0
    %
    2210

    6
    6
    %
    2218

    7
    5
    %
    2311

    8
    0
    %
    2328

    9
    0
    %
    2418

    9
    5
    %
    2506

    9
    8
    %
    2509

    9
    9
    %
    2514

    1
    00
    %
    2
    5
    14
    (longest request)

    100
    Client
    1 00
    Request


    Requests per second:
    3
    8
    .
    96
    [#/sec] (mean)


    CPU


    AWS App Runnner



    View Slide

  33. AWS Lambda
    1
    0 0
    0
    Client
    1 0
    000
    Request
    33

    100
    0
    Client
    10000
    Request


    Failed requests:
    0

    RPS 540




    560 580


    This is ApacheBench, Version
    2
    .
    3
    <$Revision:
    1
    903
    6
    18
    $>


    Copyright
    1996
    Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/


    Licensed to The Apache Software Foundation, http://www.apache.org/


    Benchmarking XxxxxxxxX.execute-api.ap-northeast-
    1
    .amazonaws.com (be patient)


    Completed
    100 0
    requests




    Completed
    100 0
    0
    requests


    Finished
    1
    0 0
    0 0
    requests


    Server Software:


    Server Hostname: XxxxxxxxX.execute-api.ap-northeast-
    1
    .amazonaws.com


    Server Port:
    44 3


    SSL/TLS Protocol: TLSv
    1
    .
    2
    ,ECDHE-RSA-AES
    1
    2
    8
    -GCM-SHA
    2 5 6
    ,
    2 0 4
    8
    ,
    1 28

    Server Temp Key: ECDH P-
    2
    56 2
    5 6
    bits


    TLS Server Name: XxxxxxxxX.execute-api.ap-northeast-
    1
    .amazonaws.com


    Document Path: /


    Document Length:
    27 496
    bytes


    Concurrency Level:
    1
    0 0
    0

    Time taken for tests:
    1 7
    .
    814
    seconds


    Complete requests:
    1
    0 000

    Failed requests:
    0

    Total transferred:
    295 1
    0 0
    0 0
    0
    bytes


    HTML transferred:
    27496 0
    00
    0
    bytes


    Requests per second:
    5 6
    1
    .
    3
    5
    [#/sec] (mean)


    Time per request:
    17 81
    .
    4 3
    0
    [ms] (mean)


    Time per request:
    1
    .
    781
    [ms] (mean, across all concurrent requests)


    Transfer rate:
    1
    6 17 7
    .
    0 9
    [Kbytes/sec] received


    Connection Times (ms)


    min mean[+/-sd] median max


    Connect:
    1
    0 1000 3 01
    .
    5 103
    2 1 7
    4 0


    Processing:
    1 26 66 2 2 85
    .
    4 61
    1 1
    80
    7

    Waiting:
    3 0 2
    5 6 1 55
    .
    3 227 12
    03

    Total:
    9
    9 1 16 6
    3 193
    .
    7 1
    6 03 3
    2 0
    1

    Percentage of the requests served within a certain time (ms)


    5
    0
    %
    1
    60 3


    6
    6
    %
    1
    66 4


    7
    5
    %
    1
    72 6


    8
    0
    %
    1
    75 0


    9
    0
    %
    1
    89 0


    9
    5
    %
    2
    05 4


    9
    8
    %
    2
    25 2


    9
    9
    %
    2
    29 5


    100
    %
    3 2
    0 1
    (longest request)

    View Slide

  34. AWS App Runner
    1 0
    00
    Client
    1
    00 0 0
    Request
    34
    This is ApacheBench, Version
    2
    .
    3
    <$Revision:
    1
    903
    6
    18
    $>


    Copyright
    1996
    Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/


    Licensed to The Apache Software Foundation, http://www.apache.org/


    Benchmarking YyyyyyyyyY.ap-northeast-
    1
    .awsapprunner.com (be patient)


    Completed
    100 0
    requests





    Completed
    100 0
    0
    requests


    Finished
    1
    0 0
    0 0
    requests


    Server Software: envoy


    Server Hostname: YyyyyyyyyY.ap-northeast-
    1
    .awsapprunner.com


    Server Port:
    44 3


    SSL/TLS Protocol: TLSv
    1
    .
    2
    ,ECDHE-RSA-AES
    1
    2
    8
    -GCM-SHA
    2 5 6
    ,
    2 0 4
    8
    ,
    1 28

    Server Temp Key: ECDH P-
    2
    56 2
    5 6
    bits


    TLS Server Name: YyyyyyyyyY.ap-northeast-
    1
    .awsapprunner.com


    Document Path: /


    Document Length:
    27 496
    bytes


    Concurrency Level:
    1
    0 0
    0

    Time taken for tests:
    5 2
    .
    278
    seconds


    Complete requests:
    1
    0 000

    Failed requests:
    1
    84 5


    (Connect:
    0
    , Receive:
    0
    , Length:
    1 8
    4 5
    , Exceptions:
    0
    )


    Non-
    2
    xx responses:
    1
    8 4
    5

    Total transferred:
    233 8
    9 7
    6 8
    0
    bytes


    HTML transferred:
    22431 4
    89
    7
    bytes


    Requests per second:
    1 9
    1
    .
    2
    8
    [#/sec] (mean)


    Time per request:
    52 27
    .
    8 1
    6
    [ms] (mean)


    Time per request:
    5
    .
    228
    [ms] (mean, across all concurrent requests)


    Transfer rate:
    4
    3 69
    .
    2
    4
    [Kbytes/sec] received


    Connection Times (ms)


    min mean[+/-sd] median max


    Connect:
    8 2 2
    2 5
    3 8
    .
    9 1
    4 1 8
    5 2


    Processing:
    1 002 41 7
    2 2
    7 5
    5
    .
    8 3
    4 8
    4 24
    1 1
    7

    Waiting:
    3 22
    6 8 1 50 7
    .
    8 2308 1
    8 1
    10

    Total:
    101 1 4395 274
    6
    .
    8 3
    69
    1 2 4
    13
    1


    Percentage of the requests served within a certain time (ms)


    5
    0
    %
    3
    69 1


    6
    6
    %
    4
    29 1


    7
    5
    %
    4
    81 2


    8
    0
    %
    6
    38 0


    9
    0
    %
    8
    81 5


    9
    5
    %
    9
    32 8


    9
    8
    %
    9
    79 1


    9
    9
    %
    1
    2 9
    4 4


    100
    %
    2
    41 3
    1
    (longest request)

    100
    0
    Client
    10000
    Request


    200 Failed requests 1845






    Failed requests 0


    280 320


    AWS Lambda



    View Slide

  35. 35
    - AWS Lambda AWS App Runner
    ×


    Bref













    FaaS PayLoad
    6
    MB
    ×

    
 



    Web cron






    1-2








    $13



    AWS




    View Slide



  36. AWS App Runner
    PHP
    36

    View Slide

  37. 05

    View Slide

  38. 38
    AWS App Runnner Web
    Point
    1
    PHP
    8
    .
    1
    Point
    2
    PHP
    Point
    3
    OSS
    Point
    4

    View Slide

  39. Thank You
    We are Hiring !


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

    View Slide