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

Running Laravel on Amazon ECS (2021)

Ernest Chiang
September 24, 2021

Running Laravel on Amazon ECS (2021)

This is the presentation deck of the talk given on 2021-09-23 at the meetup of AWSUG Taiwan. Thanks for the invitation of AWSUG Taiwan.

You can find the meetup video recording in Chinese at https://youtu.be/ge3O_4KLIzg?t=3473

`dwchiang/nginx-php-fpm` Docker image project for PHP developers:
https://hub.docker.com/r/dwchiang/nginx-php-fpm

Ernest's study notes on Amazon ECS:
https://www.ernestchiang.com/en/notes/aws/ecs/

Ernest's blog:
https://www.ernestchiang.com/

Ernest Chiang

September 24, 2021
Tweet

More Decks by Ernest Chiang

Other Decks in Technology

Transcript

  1. Ernest Chiang, 2021
    拆解整合
    將 Laravel 運⾏在 Amazon ECS
    Running Laravel on Amazon ECS

    View full-size slide

  2. Shared Notes
    • https://hackmd.io/@dwchiang/
    laravel-on-amazon-ecs-2021-
    awsug

    • 短網址:

    https://bit.ly/ecs2021awsug

    • 問與答 Q&A
    共筆筆記

    View full-size slide

  3. 拆.解.整.合.的.旅.⼈
    • PAFERS

    Product & Technology Integration

    • AWS

    Community Hero

    • ex-TSMC

    Process Integration Engineer
    Ernest Chiang

    View full-size slide

  4. COSCUP | https://bit.ly/yt-pkb
    近期分享

    View full-size slide

  5. Outline
    ⼤綱
    • 拆解整合;思路介紹

    • Laravel

    • Virtualization; Containerization; Orchestration

    • Amazon ECS

    • Laravel on Amazon ECS

    • Demo

    View full-size slide

  6. 資訊爆炸?無法消化?
    www.ErnestChiang.com
    思路

    View full-size slide

  7. 藉由拆解、定義,釐清思緒。
    1

    View full-size slide

  8. 藉由拆解、定義,釐清思緒。
    再⽤整合、組合,實現產出。
    1

    View full-size slide

  9. 藉由拆解、定義,釐清思緒。
    再⽤整合、組合,實現產出。
    1

    View full-size slide

  10. 先⼿動,再⾃動。
    2

    View full-size slide

  11. 就。很。動。
    2

    View full-size slide

  12. 1. 草稿初版流程。
    2

    View full-size slide

  13. 1. 草稿初版流程。
    2. 驗證流程產出。
    2

    View full-size slide

  14. 1. 草稿初版流程。
    2. 驗證流程產出。
    3. 找⼯具⾃動化。
    2

    View full-size slide

  15. 流程步驟
    2

    View full-size slide

  16. S. + V. + O.
    流程步驟
    2

    View full-size slide

  17. input/trigger (S.) 👉 process (V.) 👉 output (O.)
    流程步驟
    2

    View full-size slide

  18. input/trigger (S.) 👉 process (V.) 👉 output (O.)
    流程步驟
    2

    View full-size slide

  19. input/trigger (S.) 👉 process (V.) 👉 output (O.)
    ⾃動化
    2

    View full-size slide

  20. 先⼿動,再⾃動。
    2

    View full-size slide

  21. Class vs. Instance
    3

    View full-size slide

  22. Class vs. Instance
    3

    View full-size slide

  23. img src: https://commons.wikimedia.org/wiki/File:Cair_Pavarel.jpg
    Laravel
    www.ErnestChiang.com
    issues?

    View full-size slide

  24. That is Cair Paravel, the castle of the four thrones.

    View full-size slide

  25. 從 本機 開始

    View full-size slide

  26. 先⼿動,再⾃動。

    View full-size slide

  27. 我 👉 開發 👉 程式源碼
    www.ErnestChiang.com

    View full-size slide

  28. 我 👉 安裝 👉 執⾏環境
    www.ErnestChiang.com

    View full-size slide

  29. 我 👉 安裝 👉 作業系統
    www.ErnestChiang.com

    View full-size slide

  30. 我 👉 安裝 👉 ⼀台電腦
    www.ErnestChiang.com

    View full-size slide

  31. 我 👉 安裝 👉 ⼀台電腦
    我 👉 安裝 👉 作業系統
    我 👉 安裝 👉 執⾏環境
    我 👉 開發 👉 程式源碼
    www.ErnestChiang.com

    View full-size slide

  32. 我 👉 安裝 👉 ⼀台電腦 👈 別⼈做的
    我 👉 安裝 👉 作業系統 👈 別⼈做的
    我 👉 安裝 👉 執⾏環境 👈 別⼈做的
    我 👉 開發 👉 程式源碼 👈 ⾃⼰做的
    www.ErnestChiang.com

    View full-size slide

  33. 我 👉 安裝 👉 ⼀台電腦
    我 👉 安裝 👉 作業系統
    我 👉 安裝 👉 執⾏環境
    我 👉 開發 👉 程式源碼
    www.ErnestChiang.com

    View full-size slide

  34. 在我的電腦上,可以正常執⾏
    www.ErnestChiang.com

    View full-size slide

  35. 在同事電腦上,就。很。炸。
    www.ErnestChiang.com

    View full-size slide

  36. 就別提部署到量產主機了?!

    View full-size slide

  37. www.ErnestChiang.com

    View full-size slide

  38. www.ErnestChiang.com

    View full-size slide

  39. 所以?將 PHP Code 打包?

    View full-size slide

  40. 還是 加上 執⾏環境 ⼀起打包?

    View full-size slide

  41. 還是 外加 作業系統 ⼀起打包?

    View full-size slide

  42. 好,⾄少我們知道這台電腦不能打包。

    View full-size slide

  43. 就。不。包。

    View full-size slide

  44. solution?
    Virtualization
    www.ErnestChiang.com

    View full-size slide

  45. Virtualization
    虛擬化
    • Virtual

    • Virtual machine (VM)

    • Hypervisor

    • Guest OS

    • Virtual machine monitor (VMM)

    • KVM

    • Hyper-V

    • Xen

    • VirtualBox

    • QEMU

    • Docker

    • Amazon ECS

    • Kubernetes

    • OpenShift

    View full-size slide

  46. Virtualization
    虛擬化
    • Virtual

    • Virtual machine (VM)

    • Hypervisor

    • Guest OS

    • Virtual machine monitor (VMM)

    • KVM

    • Hyper-V

    • Xen

    • VirtualBox

    • QEMU

    • Docker

    • Amazon ECS

    • Kubernetes

    • OpenShift

    View full-size slide

  47. Virtualization
    虛擬化
    • Virtual

    • Virtual machine (VM)

    • Hypervisor

    • Guest OS

    • Virtual machine monitor (VMM)

    • KVM

    • Hyper-V

    • Xen

    • VirtualBox

    • QEMU

    • Docker

    • Amazon ECS

    • Kubernetes

    • OpenShift

    View full-size slide

  48. Creating a virtual version of something;

    View full-size slide

  49. Creating a virtual version of something;

    View full-size slide

  50. A hypervisor (or virtual machine monitor, VMM,
    virtualizer) is computer software, firmware or
    hardware that creates and runs virtual machines.

    View full-size slide

  51. www.ErnestChiang.com

    View full-size slide

  52. www.ErnestChiang.com

    View full-size slide

  53. img src: https://unsplash.com/photos/CJdZ800-Fbs
    part of virtualization
    Containerization
    www.ErnestChiang.com

    View full-size slide

  54. Operating-system-level virtualization, also known
    as containerization, refers to an operating system
    feature in which the kernel allows the existence
    of multiple isolated user-space instances.
    Such instances, called containers, partitions,
    virtual environments (VEs) or jails (FreeBSD jail or
    chroot jail), may look like real computers from the
    point of view of programs running in them.

    View full-size slide

  55. Operating-system-level virtualization, also known
    as containerization, refers to an operating system
    feature in which the kernel allows the existence
    of multiple isolated user-space instances.
    Such instances, called containers, partitions,
    virtual environments (VEs) or jails (FreeBSD jail or
    chroot jail), may look like real computers from the
    point of view of programs running in them.

    View full-size slide

  56. Operating-system-level virtualization, also known
    as containerization, refers to an operating system
    feature in which the kernel allows the existence
    of multiple isolated user-space instances.
    Such instances, called containers, partitions,
    virtual environments (VEs) or jails (FreeBSD jail or
    chroot jail), may look like real computers from the
    point of view of programs running in them.

    View full-size slide

  57. Operating-system-level virtualization, also known
    as containerization, refers to an operating system
    feature in which the kernel allows the existence
    of multiple isolated user-space instances.
    Such instances, called containers, partitions,
    virtual environments (VEs) or jails (FreeBSD jail or
    chroot jail), may look like real computers from the
    point of view of programs running in them.

    View full-size slide

  58. www.ErnestChiang.com

    View full-size slide

  59. www.ErnestChiang.com

    View full-size slide

  60. www.ErnestChiang.com

    View full-size slide

  61. www.ErnestChiang.com

    View full-size slide

  62. www.ErnestChiang.com

    View full-size slide

  63. www.ErnestChiang.com

    View full-size slide

  64. www.ErnestChiang.com

    View full-size slide

  65. www.ErnestChiang.com

    View full-size slide

  66. > php artisan migrate
    www.ErnestChiang.com

    View full-size slide

  67. www.ErnestChiang.com

    View full-size slide

  68. www.ErnestChiang.com

    View full-size slide

  69. www.ErnestChiang.com

    View full-size slide

  70. www.ErnestChiang.com

    View full-size slide

  71. www.ErnestChiang.com

    View full-size slide

  72. www.ErnestChiang.com

    View full-size slide

  73. www.ErnestChiang.com

    View full-size slide

  74. www.ErnestChiang.com

    View full-size slide

  75. www.ErnestChiang.com

    View full-size slide

  76. www.ErnestChiang.com

    View full-size slide

  77. www.ErnestChiang.com

    View full-size slide

  78. www.ErnestChiang.com

    View full-size slide

  79. Virtualization
    虛擬化
    • Virtual

    • Virtual machine (VM)

    • Hypervisor

    • Guest OS

    • Virtual machine monitor (VMM)

    • KVM

    • Hyper-V

    • Xen

    • VirtualBox

    • QEMU

    • Docker

    • Amazon ECS

    • Kubernetes

    • OpenShift

    View full-size slide

  80. Virtualization
    虛擬化
    • Virtual

    • Virtual machine (VM)

    • Hypervisor

    • Guest OS

    • Virtual machine monitor (VMM)

    • KVM

    • Hyper-V

    • Xen

    • VirtualBox

    • QEMU

    • Docker

    • Amazon ECS

    • Kubernetes

    • OpenShift

    View full-size slide

  81. Virtualization
    虛擬化
    • Virtual

    • Virtual machine (VM)

    • Hypervisor

    • Guest OS

    • Virtual machine monitor (VMM)

    • KVM

    • Hyper-V

    • Xen

    • VirtualBox

    • QEMU

    • Docker

    • Amazon ECS

    • Kubernetes

    • OpenShift

    View full-size slide

  82. Virtualization


    ├── Hardware-Hypervisors


    │ ├── Type 1-Native


    │ │ └── KVM, Hyper-V, QNX, VMware vSphere, Xen


    │ └── Type 2-Hosted


    │ └── bhyve, Parallerls, QEMU, VirtualBox, VMware Fusion


    └── OperatingSystem


    ├── 1-OS Containers


    │ └── FreeBSD jail, LXC, OpenVZ, Virtuozzo


    ├── 2-Application Containers


    │ └── Docker, imctfy, rkt


    └── Orchestration


    └── Amazon ECS, Kubernetes, OpenShift
    www.ErnestChiang.com

    View full-size slide

  83. Virtualization


    ├── Hardware-Hypervisors


    │ ├── Type 1-Native


    │ │ └── KVM, Hyper-V, QNX, VMware vSphere, Xen


    │ └── Type 2-Hosted


    │ └── bhyve, Parallerls, QEMU, VirtualBox, VMware Fusion


    └── OperatingSystem


    ├── 1-OS Containers


    │ └── FreeBSD jail, LXC, OpenVZ, Virtuozzo


    ├── 2-Application Containers


    │ └── Docker, imctfy, rkt


    └── Orchestration


    └── Amazon ECS, Kubernetes, OpenShift
    www.ErnestChiang.com

    View full-size slide

  84. Virtualization


    ├── Hardware-Hypervisors


    │ ├── Type 1-Native


    │ │ └── KVM, Hyper-V, QNX, VMware vSphere, Xen


    │ └── Type 2-Hosted


    │ └── bhyve, Parallerls, QEMU, VirtualBox, VMware Fusion


    └── OperatingSystem


    ├── 1-OS Containers


    │ └── FreeBSD jail, LXC, OpenVZ, Virtuozzo


    ├── 2-Application Containers


    │ └── Docker, imctfy, rkt


    └── Orchestration


    └── Amazon ECS, Kubernetes, OpenShift
    www.ErnestChiang.com

    View full-size slide

  85. Virtualization


    ├── Hardware-Hypervisors


    │ ├── Type 1-Native


    │ │ └── KVM, Hyper-V, QNX, VMware vSphere, Xen


    │ └── Type 2-Hosted


    │ └── bhyve, Parallerls, QEMU, VirtualBox, VMware Fusion


    └── OperatingSystem


    ├── 1-OS Containers


    │ └── FreeBSD jail, LXC, OpenVZ, Virtuozzo


    ├── 2-Application Containers


    │ └── Docker, imctfy, rkt


    └── Orchestration


    └── Amazon ECS, Kubernetes, OpenShift
    www.ErnestChiang.com

    View full-size slide

  86. img src: https://unsplash.com/photos/aEnH4hJ_Mrs
    arrangement
    Orchestration
    www.ErnestChiang.com

    View full-size slide

  87. www.ErnestChiang.com

    View full-size slide

  88. www.ErnestChiang.com

    View full-size slide

  89. www.ErnestChiang.com

    View full-size slide

  90. 1 2
    www.ErnestChiang.com

    View full-size slide

  91. img src: Photo by sergio souza on Unsplash
    orchestration
    Amazon ECS
    www.ErnestChiang.com

    View full-size slide

  92. www.ErnestChiang.com

    View full-size slide

  93. www.ErnestChiang.com

    View full-size slide

  94. www.ErnestChiang.com

    View full-size slide

  95. www.ErnestChiang.com

    View full-size slide

  96. www.ErnestChiang.com

    View full-size slide

  97. www.ErnestChiang.com

    View full-size slide

  98. www.ErnestChiang.com

    View full-size slide

  99. www.ErnestChiang.com

    View full-size slide

  100. www.ErnestChiang.com

    View full-size slide

  101. img src: Photo by sergio souza on Unsplash
    on Amazon ECS
    Running Laravel
    www.ErnestChiang.com

    View full-size slide

  102. www.ErnestChiang.com

    View full-size slide

  103. www.ErnestChiang.com

    View full-size slide

  104. www.ErnestChiang.com

    View full-size slide

  105. www.ErnestChiang.com
    ECR

    View full-size slide

  106. S. (I) V. O. (image)
    ECR
    www.ErnestChiang.com

    View full-size slide

  107. S. (ECS)
    V.
    O.
    ECR
    www.ErnestChiang.com

    View full-size slide

  108. S. (CI)
    V.
    O.
    CI
    www.ErnestChiang.com

    View full-size slide

  109. www.ErnestChiang.com

    View full-size slide

  110. www.ErnestChiang.com Search "ernest laravel ecs workshop" to download.

    View full-size slide

  111. www.ErnestChiang.com Search "ernest laravel ecs workshop" to download.

    View full-size slide

  112. Demo
    www.ErnestChiang.com
    never live demo!

    View full-size slide

  113. 參考資料
    www.ErnestChiang.com
    Reference

    View full-size slide

  114. 參考資料
    Virtualization
    • Wikipedia - Virtualization

    • https://en.wikipedia.org/wiki/Virtualization

    • Playing With Firecracker VMM at COSCUP 2020

    • https://www.ernestchiang.com/en/posts/2020/playing-with-
    fi
    recracker/

    • Firecracker

    • https://
    fi
    recracker-microvm.github.io/

    View full-size slide

  115. 參考資料
    Virtualization
    • Linux 核⼼設計_發展動態回顧

    • https://www.youtube.com/watch?v=-2Pn4B8S1EM

    • Embedded Virtualization applied in Mobile Devices

    • https://www.slideshare.net/jserv/mobile-virtualization

    View full-size slide

  116. 參考資料
    Containerization
    • Wikipedia - OS-level virtualization

    • https://en.wikipedia.org/wiki/OS-level_virtualization

    View full-size slide

  117. 參考資料
    Orchestration
    • Docker image of nginx + php-fpm (amd64/arm64)

    • https://hub.docker.com/r/dwchiang/nginx-php-fpm

    View full-size slide

  118. 參考資料
    Amazon ECS
    • My study notes

    • https://www.ernestchiang.com/en/notes/aws/ecs/

    • Nathan Peck's Awesome List

    • https://github.com/nathanpeck/awesome-ecs

    • 技術選型: Amazon ECS Launch Types: EC2 vs. Fargate

    • https://www.ernestchiang.com/zh/posts/2020/technology-selection-amazon-ecs-launch-
    type/

    • 5 Steps: Using Amazon ECS Exec to pass through Fargate/ECS into containers

    • https://www.ernestchiang.com/en/posts/2021/using-amazon-ecs-exec/

    View full-size slide

  119. 參考資料
    Running Laravel on Amazon ECS
    • Workshops: Running Laravel on AWS ECS (using CDK)

    • https://github.com/dwchiang/laravel-on-aws-ecs-workshops

    • CDK Construct Hub

    • https://constructs.dev/

    • CDK patterns for modern application with serverless containers on AWS

    • https://github.com/aws-samples/serverless-container-constructs

    • My study notes on CDK

    • https://www.ernestchiang.com/en/notes/aws/cdk/

    View full-size slide

  120. Virtualization software

    View full-size slide

  121. Search "ernest aws ecs" to download.

    View full-size slide

  122. Ernest's Blog
    • https://www.ernestchiang.com
    拆 / 解 / 整 / 合

    View full-size slide

  123. Ernest's Newsletter
    • https://bit.ly/3B2ksae
    拆 / 解 / 整 / 合 電⼦報

    View full-size slide

  124. 問與答
    www.ErnestChiang.com
    更多對話

    View full-size slide

  125. Shared Notes
    • https://hackmd.io/@dwchiang/
    laravel-on-amazon-ecs-2021-
    awsug

    • 短網址:

    https://bit.ly/ecs2021awsug

    • 問與答 Q&A
    共筆筆記

    View full-size slide