(Image source: Photo by Jason Dent on Unsplash)
Over the past few years, I have continued to find some time to sort out the learning, and some of the results will be released as open source. I hope to bring out some ideas, considerations, various discussions and exchanges. It contains PHP, which I have never abandoned. The original design purpose of the container that I have organized this time is to combine php-fpm and nginx to form a simplified environment that can easily enable Laravel to operate in a cloud-native environment, AWS Fargate, Amazon ECS and other environments, to achieve application-first goal. I use it as a base for training, consulting and implementation of several teams, various comparison tests, including future comparisons of x86/ARM computing architectures, and so on.
- The released Docker image is placed in Docker Hub: dwchiang/nginx-php-fpm
- The original Dockerfiles are placed in GitHub: dwchiang/nginx-php-fpm
- If you like this project, feel free to use it into your project, or share it with friends, or click a star for this project ⭐ :)
- If you’re also interested in the topic Running Laravel on Amazon ECS, you might find these resources useful:
- This self-paced online workshop with complete architecture diagrams: dwchiang/laravel-on-aws-ecs-workshops,
- Or my presentation, which includes slides and a recording: Running Laravel/PHP Container Applications on AWS (AWS Builders Day Taiwan 2022)
This article may be updated in the future.
Contents
About Comparison
Sorting out this kind of comparative data, from the steps of design environment, implementation, measurement, data collection, sorting, drawing, summary and induction, etc., is full of brainstorming and fun. If there are any points in the content that can be adjusted or improved, or suggest using some other measurement methods, please leave a message or open an issue to me, thank you very much.
In addition, I would like to ask for advice. Are there any tools or methods that allow you to test and collect data in multiple ways, and then integrate them for comparison? I think my single-computer test volume is too small (slow).
Laravel 8.49.1 with PHP 7.4.21 on Different Docker Base Images
Test purpose
- Performance comparison on Laravel 8.49.1 with different Docker base images
Test variables
- Test #1: Dockerfile uses dwchiang/nginx-php-fpm as the Docker base image
- Test #2: Dockerfile (https://github.com/dwchiang/nginx-php-fpm/blob/master/Dockerfile-8.5.20-laravel-bitnami) uses bitnami/laravel as the Docker base image
Test environment
- MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)
- CPU 2 GHz Quad-Core Intel Core i5 (x86)
- Docker-compose container condistions:
- 1 CPU
- 512m memory
Test pages
- Default Homepage: Laravel default welcome homepage
Test preparation
- Each test uses a clean container environment to minimize interference during the test.
- Concurrent 1
- Duration 60 seconds (1 minute)
Test date
- 2021-0706
Test result
- Container Image Size
- Test Page: Default Homepage
Analysis
- Comparison between
dwchiang/nginx-php-fpm
andbitnami/laravel
:
dwchiang/nginx-php-fpm bitnami/laravel OS_ARCH linux/arm64
andlinux/amd64
only linux/amd64
OS buster
bitnami/minideb
Packages flexibility HTTP Server nginx PHP’s built-in development server PHP Version 7.4.21 7.4.21 Laravel Version 8.49.1 8.49.1 - Comparison between
Conclusion
- Docker image bitnami/laravel (or a container using PHP’s built-in HTTP Server) is suitable for quickly building a development environment on the machine, but not necessarily suitable for use in a production environment.
Laravel 8.19.0 with PHP 8.0/7.4/7.3 on Buster/Alpine 3.12
- Test purpose
- Performance comparison on Laravel 8.19.0 with different PHP versions (8.0/7.4/7.3) and different base OS (Buster/Alpine 3.12)
- Test environment
- MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)
- CPU 2 GHz Quad-Core Intel Core i5 (x86)
- Docker-compose container condistions:
- 1 CPU
- 512m memory
- Nginx: 1.18.0
- Test pages
- Default Homepage: Laravel default welcome homepage
- Names: First seed 50 (fake) users into the database (using Docker-compose to bring them up), and then read all users from the database, and display the names of these 50 users on the page. (Note: The route/seed syntax of Laravel 7/8 has been changed.)
- Test preparation
- Each test uses a clean container environment to minimize interference during the test.
- Concurrent 1
- Duration 60 seconds (1 minute)
- Test date
- 2021-0417
- Test result
- Container Image Size
- Test Page: Default Homepage
- Test Page: Names