Sylius-Standard icon indicating copy to clipboard operation
Sylius-Standard copied to clipboard

Speed up PHP-fpm container on MacOS

Open tonicospinelli opened this issue 3 years ago • 6 comments

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 avatar Jun 02 '21 04:06 tonicospinelli

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.

tonicospinelli avatar Jun 02 '21 04:06 tonicospinelli

@vvasiloi I fix the typos 😊

tonicospinelli avatar Jun 09 '21 16:06 tonicospinelli

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

vvasiloi avatar Jun 09 '21 18:06 vvasiloi

@Arminek can you take a look into this?

lchrusciel avatar Nov 19 '21 15:11 lchrusciel

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 :)

Ferror avatar May 11 '22 12:05 Ferror

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

jacquesbh avatar May 11 '22 12:05 jacquesbh