Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up PHP-fpm container on MacOS #568

Draft
wants to merge 2 commits into
base: 1.12
Choose a base branch
from

Conversation

tonicospinelli
Copy link

Many MacOS users may be facing slow responses from Shop or Admin when
running the sylius application in the container. The main reason is how
docker was build in the MacOS architecture. The PHP application has
thousands of files to be loaded in memory (vendor directory mainly).

So, to decrease the page response time, the vendor directory is not
synced into the container. It will be ignored by docker-composer.yml
using the named volume.

Also, was added a health check for the PHP-fpm container to know when it
is ready. If you want to check healthiness, just run the command
docker-compose ps to see the container State.

The HEALTHCHECK instruction tells Docker how to test a container
to check that it is still working. This can detect cases such as a
web server stuck in an infinite loop and unable to handle new
connections, even though the server process is still running.

The PHP and PHP-FPM configurations received some adjustments to get
better support development environment experience using containers.

I did pick up these updates from two other contributors that I
co-authored in this commit.

Co-authored-by: Kévin Dunglas [email protected]
Co-authored-by: arti0090 [email protected]

@tonicospinelli tonicospinelli requested a review from a team as a code owner June 2, 2021 04:35
@tonicospinelli tonicospinelli force-pushed the docker-speedup branch 2 times, most recently from 5e74470 to 22a1445 Compare June 2, 2021 04:41
@tonicospinelli
Copy link
Author

tonicospinelli commented Jun 2, 2021

In the environment with APP_DEV = dev and APP_DEBUG = 1, the response time is around ~2s or more.
As for APP_DEV = prod and APP_DEBUG = 0, the response time is about ~350ms or more.

Of course, it depends on your workstation and the resources available for the containers. Therefore, I got a better experience in the local environment with these changes.

Always the first request took more time than I mentioned above, it is because the PHP is caching code on opcache and Symfony generating the cache files.

.env.prod Outdated Show resolved Hide resolved
@tonicospinelli tonicospinelli changed the title Speed up PHP-fpm container on MacOS Speed up PHP-fpm container Jun 2, 2021
@tonicospinelli tonicospinelli changed the title Speed up PHP-fpm container Speed up PHP-fpm container on MacOS Jun 2, 2021
docker-compose.yml Outdated Show resolved Hide resolved
Many MacOS users may be facing slow responses from Shop or Admin when
running the sylius application in the container. The main reason is how
docker was build in the MacOS architecture. The PHP application has
thousands of files to be loaded in memory (vendor directory mainly).

So, to decrease the page response time, the vendor directory is not
synced into the container. It will be ignored by docker-composer.yml
using the named volume.

Also, was added a health check for the PHP-fpm container to know when it
is ready. If you want to check healthiness, just run the command
`docker-compose ps` to see the container State.

The HEALTHCHECK instruction tells Docker how to test a container
to check that it is still working. This can detect cases such as a
web server stuck in an infinite loop and unable to handle new
connections, even though the server process is still running.

The PHP and PHP-FPM configurations received some adjustments to get
better support development environment experience using containers.

I did pick up these updates from two other contributors that I
co-authored in this commit.

Co-authored-by: Kévin Dunglas <[email protected]>
Co-authored-by: arti0090 <[email protected]>
The container image was ignoring the dotenv config to build the PHP
container image.
@tonicospinelli
Copy link
Author

@vvasiloi I fix the typos 😊

@vvasiloi
Copy link
Contributor

vvasiloi commented Jun 9, 2021

I keep using the wrong account...
Looks good, but we still have to wait for a maintainer to approve.

@lchrusciel
Copy link
Member

@Arminek can you take a look into this?

@Ferror
Copy link
Contributor

Ferror commented May 11, 2022

It's a nice improvement, but with the latest Docker Desktop filesystem, there is no need for performance improvement.

https://www.docker.com/blog/speed-boost-achievement-unlocked-on-docker-desktop-4-6-for-mac/

I don't mind keeping the health checks in the environment :)

@jacquesbh
Copy link
Member

@Ferror Docker for mac still has some issues unresolved :). But soonish I hope!

@Ferror Ferror marked this pull request as draft May 31, 2022 14:41
@Ferror Ferror added the Docker Docker-related issues and PRs. label May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docker Docker-related issues and PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants