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

アンチパターンに踏み込む -作って理解するサーバーレスPHPフレームワーク / Stepping into anti-patterns -Serverless PHP frameworks to build and understand -.

アンチパターンに踏み込む -作って理解するサーバーレスPHPフレームワーク / Stepping into anti-patterns -Serverless PHP frameworks to build and understand -.

shiro seike

October 07, 2023
Tweet

More Decks by shiro seike

Other Decks in Programming

Transcript

  1. PHP Conference Japan 2 0 23 2 0 23 .

    10 . 8 @seike 4 60 1 - PHP -
  2. 自己 @seike 46 0 - - @seike 46 0 -

    AWS Community Builder Serverless - Fusic - / 門 - / - - PHP - PHP - PHP - - Fukuoka.php - PHP 2023 行 長 2
  3. Agenda 1 .AWS Lambda 2 .Web AWS Lambda 3 .

    一 4 . 自 用 5 . 小 方 用 6 . 3
  4. AWS Lambda 小 Lambda 生 行 生 小 小 行

    小 Lambda 行 長 行 VPC 力 用 ⾒ Lambda VPC 行 VPC Lambda 行 生 用 Lambda SecretManager 用 AWS CloudWatch Logs CloudWatch Metrics 用 Lambda 6
  5. Bref Bref PHP OSS 一 AWS Lambda PHP AWS Lambda

    PHP PHP 大 PHP 用 Bref PHP PHP   AWS Lambda 用 Developer Community   Laravel Symfony 人 PHP   CLI 8
  6. Developer Community AWS Lambda PHP 用 PHP PHPer 辛 Bref

    Serverless Framework 力 9 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
  7. 10 Bref AWS Lambda API Gateway 行 Bref API Gateway

    AWS Lambda Bref Laravel Bridge Laravel Bref Lambda
  8. Laravel Bref 12 Laravel Bref PHP 用 AWS Lambda PHP

    用 AWS Lambda AWS Lambda Laravel PHPer 大
  9. AWS Lambda 14 小 Lambda 生 行 生 大 小

    小   入 行 小 Lambda 行 長 行 PHP 長 VPC 力 用 ⾒ Lambda VPC 行 VPC Lambda 行 生 用 Lambda SecretManager 用 AWS CloudWatch Logs CloudWatch Metrics 用 Lambda
  10. Lambda Amazon Web Services Operating Lambda: – Part 3 -Lambda

    - - 小 用 - - - - 用 - 15 URL:https://aws.amazon.com/jp/blogs/news/compute-operating-lambda-anti-patterns-in-event-driven-architectures-part- 3 / Operating Lambda: – Part 3
  11. 一 Laravel 用 言 用 力 生 行 生 力

    生 高 一 Laravel 一 文 文 Laravel Web 言 文 非 文 20
  12. 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 22
  13. AWS Lambda x Bref x Laravel 23 用 大 行

    - AWS Lambda - AWS S 3 Select - S 3 JSON SQL 用 大 行 PHP AWS Lambda 行 一 入 Laravel
  14. AWS Lambda x Bref x Laravel 用 24 Web AWS

    Lambda Bref Laravel ⾒ 手 0 Laravel Laravel 行 自 Laravel 用 AWS ⾒
  15. ChatGPT ・ ORM ・ ・ ・ API 生 RESTful API

    GraphQL HTTP 34 CI/CD ⾒ API ⾒ Webhook OAuth (RBAC) API (XSS) (CSRF) SQL (CSP) HTTPS/SSL (SSO)
  16. Request GET POST URL Router URL Response DbManager DBRepository DbRepository

    Controller 行 View 示 Session Application ClassLoader 自 PHP P. 202 38
  17. API Gateway 40 - Client Cognito ID - Client ID

    API Gateway Request - API Gateway Authorizer Cognito - API 用 API Gateway CORS 行
  18. 46 ├ ─ ─ ThinApiApplication.php ├ ─ ─ bootstrap.php ├

    ─ ─ composer.json ├ ─ ─ composer.lock ├ ─ ─ controllers │ └ ─ ─ ApiController.php ├ ─ ─ core │ ├ ─ ─ Application.php │ ├ ─ ─ ClassLoader.php │ ├ ─ ─ Controller.php │ ├ ─ ─ HttpNotFoundException.php │ ├ ─ ─ Request.php │ ├ ─ ─ Response.php │ └ ─ ─ Router.php ├ ─ ─ serverless.yml └ ─ ─ web └ ─ ─ index.php API ThinApiApplication 比 行 示 非 小
  19. deploy 自 56 Deploying app-bref-thin to stage dev (ap-northeast-1) ✔

    Service deployed to stack app-bref-thin-dev (28s) endpoint: ANY - https://zzzzzzzzzz.execute-api.ap-northeast-1.amazonaws.com functions: api: app-bref-thin-dev-api (275 kB) Want a better experience than the AWS console? Try out https://dashboard.bref.sh 28 27 5 kB
  20. deploy Laravel 57 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 28 -> 52 275kB -> 3 2 M Laravel 入 ⾒ 小
  21. [#/sec] 自 58 Requests per second: 285.36 [#/sec] (mean) Requests

    per second: 347.26 [#/sec] (mean) Requests per second: 328.23 [#/sec] (mean) EC 2 Apache Bench 347 . 26 [#/sec] Response index.php 351.97[#/sec] 3
  22. [#/sec] Laravel 59 $ ab -n 20000 -c 10 https://yyyyyyyyyy.execute-api.ap-northeast-1.amazonaws.com/

    ~ Requests per second: 295.31 [#/sec] (mean) Requests per second: 303.91 [#/sec] (mean) Requests per second: 307.67 [#/sec] (mean) ~ EC 2 Apache Bench 347 . 26 [#/sec] -> 307 . 67 [#/sec] Laravel 言 3
  23. 用 Role APIGateway ⾒ 示 63 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)
  24. Amazon Web Services - Labs OSS Amazon Web Services Labs

    OSS 非 OSS 自 用 人 Runtime Bref 用 66
  25. 小 小   : 人   :   用 :

      : 用   : AWS 68
  26. 小 小   : 人   :   用 :

      : 用   : AWS 69
  27. 方 方   : 人   :   用 :

      : 用   : AWS 70
  28. 72 入 目 用 Point 1 力 Point 2 Monolith

    First Serverless Development 方 Laravel Point 3 方 小 Laravel Point 4