Question
What is the difference between FastCGI, FPM and dedicated FPM served by nginx or Apache PHP handlers in Plesk?
Answer
Briefly saying, their major difference is in site isolation level - the more isolated the handler is, the more secure it is to use. In ascending order:
- FastCGI
- FPM
- Dedicated FPM
Performance impact is another difference.
FastCGI is an improved version of the CGI handler used in the old PHP versions. FastCGI has better security than CGI: its process runs on behalf of the Plesk subscription's system user instead of the Apache user. Having fewer privileges limits the attacker's actions in case the subscription user is compromised.
Compared to FPM, FastCGI is slower and generally consumes more RAM.
PHP-FPM (FastCGI Process Manager) is a process manager for FastCGI SAPI (Server API). It is more secure, faster, and consumes less RAM compared to FastCGI. More details are available on this blog page: https://www.plesk.com/blog/various/why-do-you-need-php-fpm/
The downside is that all FPM processes have one point of failure - a common master process. All websites with the same PHP handler on PHP-FPM use a single FPM master, which means that:
- All sites use a single OPcache cache because the cache is bound to the master
- In case any PHP settings are changed or a site is added or removed from the handler, the master will be restarted, which means that all active requests to all websites on this handler are terminated and can return errors 502
- In case the PHP-FPM master crashes, all sites with this PHP handler will be down.
Dedicated FPM introduces more granular control for PHP-FPM master processes: per subscription or per-domain. This means improved stability and isolation for Plesk websites working with PHP-FPM handlers.
However, this leads to increased load on the server.
Consider the following when chosing between FPM served by Apache or FPM served by nginx in Domains > example.com > PHP Settings:
- Nginx is faster at handling static content. It consumes fewer resources to maintain keep-alive connections.
- Nginx + PHP FPM and Apache + PHP FPM combinations perform the same when handling dynamic content
-
Apache has more modules and managing permissions via
.htaccess
directives, making it more universal
Generally, it is recommended to enable FPM served by nginx for better site performance and lower CPU load. It is also recommended to keep proxy mode enabled in Domains > example.com > Apache & nginx Settings because it allows both Apache and nginx to handle the tasks they are the best suited for.
If nginx is selected, existing .htaccess
rules for Apache should be converted to nginx syntax: How to keep .htaccess rules after switching PHP handler from Apache to nginx in Plesk?
Comments
0 comments
Please sign in to leave a comment.