fballiano / docker-magento2

Cluster ready Magento2 + Varnish 7 + PHP 8.1 + Redis 6.2 + Elasticsearch 7.17 + SSL
355 stars 164 forks source link

Why not use PHP-FPM ? #35

Open quenode opened 5 years ago

quenode commented 5 years ago

Hi thank you very much for this project,

I was wondering any advantage of using PHP-FPM vs Apache2 (Modphp option)

Tnx

fballiano commented 5 years ago

there were other projects using FPM, also I never liked FPM 100%.

I think FPM it's great for website that serve static content (or pages generated by other languages) + some percentage of PHP pages, but with magento most of the requests are PHP handled, thus I think it's always better to have them directly inside the web server. All non-php requests (in this infrastructure at least) are cached by varnish never to be served again so actually (with warm cache) all requests are PHP requests.

Also, apache handles htaccess.

I've to say that now that SSL is a must and we've to have nginx as SSL incapsulator (which this project have since a while now)... it would make sense to migrate to FPM and get rid of apache, which would mean removing 1 component from the infrastructure and making it more simple, but I still like the htaccess support a lot.

fballiano commented 5 years ago

actually I'm not sure it would work cause nginx is before varnish, thus after varnish we'd need another web server before FPM right? if that's the case I can't see any benefit in switching.

ThomasNegeli commented 5 years ago

@fballiano when you look at the network of your browser, you see that a minimum of Magento requests are PHP requests. Most of them are static content requests, which can be directly served without coming to the PHP interpreter.

Mixing the PHP interpreter and the webserver, as it is when you install Magento and Apache with PHP in the same container, does not take into account that there should be one container for one job. Only when you respect this you have the benefit if exchanging components in the infrastructure, without influencing each other.

fballiano commented 5 years ago

all those requests are cached and served by varnish