المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : شرح مميزات PHP-FPM وما الافضل ؟ PHP-FPM Status: Off ام PHP-FPM Status: on



Rise Company
10-04-2020, 07:40
شرح مميزات PHP-FPM وما الافضل ؟ PHP-FPM Status: Off ام PHP-FPM Status: on
يعنى اى كلمة pool فى PHP-FPM - شرح معنى بول pool داخل PHP-FPM
اعمل pool واحد فقط ام اعمل Multi pool فى PHP-FPM

https://www.rise.company/upload/uploads/15864966278861.png

------------------------------------------------
شرح مميزات PHP-FPM
------------------------------------------------

الفكرة :
اذا كان لديك حمام سباحة Pool واحد كبير وبسلم واحد ولديك الكثير من العملاء هيقفوا طابور على السلم
اما اذا كان لديك اكثر من حمام سباحة Pool صغير و كل حمام له سلمه الخاص هيتوزع على جميع العملاء

النتيجة :
حمام السباحة الكبير : هناك بطىء فى الدخول و الخروج من سلم واحد
ولكن لا يوجد استنذاف لبعض الموارد فى انشاء حمام واحد فقط
فمهما زاد عدد العملاء لديك حمام سباحة واحد ولكن كبير ويسع الجميع
ولكن يفقد الخصوصية و الحماية !

حمام السباحة الصغير : هناك سرعة لان لكل عميل حمام خاص به
ولكن يوجد استنفاذ لبعض الموارد فى انشاء لكل عميل حمام خاص به
اذن كم لديك من عميل لكى تعمل له حمام سباحة خاص به فقط
ولكن يتمتع بميزة الخصوصة و الحماية !

شاهد ايضا :
مميزات / فائدة php fpm pool لعزل كل موقع عن الاخر داخل السيرفر (https://www.rise.company/forum/threads/31053-%D9%85%D9%85%D9%8A%D8%B2%D8%A7%D8%AA-%D9%81%D8%A7%D8%A6%D8%AF%D8%A9-php-fpm-pool-%D9%84%D8%B9%D8%B2%D9%84-%D9%83%D9%84-%D9%85%D9%88%D9%82%D8%B9-%D8%B9%D9%86-%D8%A7%D9%84%D8%A7%D8%AE%D8%B1-%D8%AF%D8%A7%D8%AE%D9%84-%D8%A7%D9%84%D8%B3%D9%8A%D8%B1%D9%81%D8%B1)

------------------------------------------------
فى حالة PHP-FPM Status: Off
------------------------------------------------

فى حالة PHP-FPM Status: Off تكون الطلبات على السيرفر طلب طلب اى طابور واحد طويل و بالدور
الميزة : لود قليل على موارد السيرفر | العيب : الطلبات تاخذ طابور واحد وبطىء فى تنفيذ الكثير من الطلبات

https://www.rise.company/upload/uploads/158649681950022.png

------------------------------------------------
فى حالة PHP-FPM Status: on
------------------------------------------------

فى حالة PHP-FPM Status: on تكون الطلبات على السيرفر اكثر من طلب فى المرة الواحدة بدون حدوث طابور طويل
الميزة : كل طلب له pool خاص به و بالتالي تنفيذ الكثير من الطلبات | العيب : لود عالى لوجود لكل دومين pool خاص به بدل واحد مشترك

https://www.rise.company/upload/uploads/158649681966493.png

------------------------------------------------
ما الافضل ؟ PHP-FPM Status: Off ام PHP-FPM Status: on
------------------------------------------------

فى حالة PHP-FPM Status: on

هى الافضل و الاسرع ولكن هناك لود عالية اى ضغط عمل
فاذا كانت امكانيات السيرفر عالية نسبة و تناسب بين عدد العملاء و امكانيات السيرفر
وبالتالى كل عميل يكون له حمام سباحة خاص به اى pool خاص به , كل عميل له طابور خاص به

فى حالة PHP-FPM Status: on المواصفات هي :

https://www.rise.company/upload/uploads/158649681934081.png

اقل شىء لعمل السيرفر للـ PHP-FPM هو 2 GB رام وهذا لا يوجد مشكلة منه
ولكن ماذا عن Domain Ram اى لكل عميل pool هياخذ 30 MB من الرام
فاذا لديك 100 عميل فيتم اخذ الحد الادني من الرام 3000 MB اى 3 جيجا
وهو مقبول وخاصة اذا كان لديك سيرفر خاص 16 جيجا رام مثلا

فى حالة PHP-FPM Status: off

لن تجد ارتفاع فى اللود ولن تشعر ببطىء حقيقى وينصح بها فى حالة كان لديك الكثير من العملاء مثلا: 1000 عميل
ولكن يفضل دائما ان تجعلها on لان الحماية هى رقم 1 دائما مع العلم انه تم التجربة على 100 عميل فقط

فى حالة PHP-FPM Status: on كانت النتيجة لا يوجد زيادة ملحوظة فى البروسيسور / الرام
فى حالة PHP-FPM Status: off كانت النتيجة لا يوجد نقص ملحوظ فى البروسيسور / الرام
الفرق بيسط جدا على سيرفر معتدل فى الامكانيات و عدد العملاء عليه

ملحوظة : هذا الموضوع هو اجتهاد نتمنى من الجميع المشاركة ايضا للمزيد من التوضيح و التجارب

شرح الفرق و مميزات ؟ PHP-FPM Status: Off ام PHP-FPM Status: on

https://www.youtube.com/watch?v=qNQSdy0eflo


------------------------------------

How to Use PHP-FPM with cPanel PHP performance is an enduring issue for web hosts. PHP is the most widely used server programming language on the web by a big margin. The most popular content management systems and ecommerce applications are written in PHP, including WordPress®, Joomla, Drupal, Magento®, and dozens more.
The ultra-fast PHP-FPM accelerates PHP execution on busy web servers, making it a valuable tool in the fight against slow sites and resource-constrained servers.
This article takes a deep dive into how PHP-FPM works and explains how to deploy and configure it with cPanel & WHM.
What is PHP-FPM? PHP-FPM is an alternative PHP implementation that makes busy web applications faster while helping system administrators to control resource consumption on their server.
A PHP implementation, also known as the runtime, interprets and executes code. Traditional runtimes such as Apache’s mod_PHP do their work within the web server. That approach has advantages, but each connection consumes a chunk of the server’s resources for as long as it lasts. If there are too many concurrent connections, the server may run out of resources like memory altogether, impacting the performance of every site it hosts.
PHP-FPM does things differently: it operates outside of the web server and uses a pool of worker processes to execute code. The workers are ready and waiting when a request comes in, and you can control how many workers are in the pool so they can’t multiply until they consume all the server’s RAM and processor time.
It works like this:
https://www.rise.company/forum/images/imported/2020/04/89.png

Apache sends code to PHP-FPM over a high-speed binary interface called FastCGI.
A supervisor process chooses a worker process from the pool and gives it the code.
The worker executes the code, and the result is sent back to Apache, which sends it to the web browser.
Once the worker is done, it returns to the pool to await another chunk of code to execute.

If there are too many concurrent connections, some might have to wait for a free worker, but they will never consume all of the server’s resources. On a busy web server, worker pools are faster and more efficient than other strategies.
Getting Started with PHP-FPM in CentOS and EasyApache It is straightforward to activate and configure PHP-FPM in cPanel & WHM. You can choose which domains use it and set configuration variables that influence its behavior.
The first step is to turn it on in the System PHP-FPM settings in WHM’s MutliPHP Manager.
https://www.rise.company/forum/images/imported/2020/04/90.png When you click Turn On, WHM makes PHP-FPM available, but it doesn’t activate it for all domains automatically. You can force all accounts on the server to use PHP-FPM by clicking Convert All Accounts to PHP-FPM.
https://www.rise.company/forum/images/imported/2020/04/91.png Alternatively, you can activate PHP-FPM for individual domains in the table at the bottom of this page. To turn it on for several domains at once, select them in the table and choose On in the drop-down menu.
https://www.rise.company/forum/images/imported/2020/04/92.png Configuring PHP-FPM in cPanel Once you have activated PHP-FPM, you can configure both the system defaults and the settings for individual domains in MultiPHP Manager.
Click the System PHP-FPM Configuration tab.
https://www.rise.company/forum/images/imported/2020/04/93.png In this section, there are three pool settings you can change. These are the default values that are applied to domain pools.


Max Requests: The number of requests each worker process should execute before it restarts itself. This setting is useful for working around memory leaks. The default of 20 is acceptable for most web hosting scenarios, but you may want to increase it to between 40 and 60 on servers with heavy traffic.
Process Idle Timeout: How long an idle worker process will wait before shutting down. Idle processes consume resources, so we don’t want too many hanging around, but we don’t want to kill them too soon because it takes a while to start new ones. The default of 10 (seconds) may be too low for a busy server.
Max Children: The maximum number of worker processes in each pool. The default is 5.

Many factors affect the optimal values for these settings, including the code your server runs and the amount of RAM it has. We wrote PHP-FPM Performance Tuning Basics (https://support.cpanel.net/hc/en-us/articles/360036533754-PHP-FPM-Performance-Tuning-Basics)to help you decide on the correct values for your server.
https://www.rise.company/forum/images/imported/2020/04/94.png Underneath the pool options are PHP INI directives. We surface several of the most useful in the interface, and you can find more information about them in PHP’s Runtime Configuration documentation (https://www.php.net/manual/en/filesystem.configuration.php). We’ll show you how to add other directives in the next section.
In addition to system-wide configuration, you can also configure individual domains in the WHM interface.
https://www.rise.company/forum/images/imported/2020/04/95.png In the table at the bottom of MutliPHP Manager, click Edit PHP-FPM at the end of the domain’s row. The options that appear are identical to those in the system-wide configuration interface.
https://www.rise.company/forum/images/imported/2020/04/96.png How the cPanel PHP-FPM Module Works Although the WHM interface contains the most useful configuration options, there are many more in the documentation (https://www.php.net/manual/en/install.fpm.configuration.php). To add or modify them, you will need to edit configuration files on the server’s command line (https://docs.cpanel.net/cpanel/security/ssh-access/) or in the cPanel & WHM File Manager.
The two most important system-wide configuration files are:


/var/cpanel/ApachePHPFPM/system.yaml
/var/cpanel/ApachePHPFPM/system_pool_defaults.yaml

WHM doesn’t create these files because the system doesn’t need them, but you can create them yourself and add directives to override the defaults.
touch /var/cpanel/ApachePHPFPM/system.yaml
touch /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml You may also have to create the directory with:
mkdir -p /var/cpanel/ApachePHPFPM/ In these files, enter only directives that differ from and override the system directives. For example, if you wanted to change the emergency_restart_threshold directive from the default of 0, the system_pool_defaults.yaml file would look like this:
https://www.rise.company/forum/images/imported/2020/04/97.png The three dashes at the top of the file (———) are part of the YAML markup language and must be present. The configuration file won’t work without them.
In the PHP documentation, you will find directives formatted with periods (.) and other symbols; syslog.facility,for example. When adding directives to configuration files, these symbols must be replaced with an underscore (_). For example, instead of syslog.facility, use syslog_facility.
You can learn more about configuring the cPanel PHP-FPM module in Configuration Values of PHP-FPM (https://docs.cpanel.net/knowledge-base/php-fpm/configuration-values-of-php-fpm/) and PHP-FPM Code and FileSystem Layout for EasyApache 4 (https://docs.cpanel.net/knowledge-base/php-fpm/php-fpm-code-and-filesystem-layout-for-easyapache-4/).
Creating User Pools in PHP-FPM Finally, we’ll look at manually creating and configuring domain-specific user pools in PHP-FPM. These are the worker pools used by sites hosted on your server’s domains.
The PHP-FPM module creates a worker pool for a domain if it finds a configuration file in:
/var/cpanel/userdata/[user]/[domain].php_fpm.yaml Replace [user] and [domain] with the relevant values for your server. You can create this file or activate PHP-FPM for a domain in WHM and it will be created automatically.
https://www.rise.company/forum/images/imported/2020/04/98.png At a minimum, the file must contain the following information:
As with the system files, you can add directives to configure the user pools. After creating or editing the .yaml file, run the following command:
/scripts/php_fpm_config – rebuild
The script adds directives to Apache’s config file and restarts PHP-FPM, after which the new pool will be up and running. You can find more information about creating user pools in PHP-FPM User Pools (https://docs.cpanel.net/knowledge-base/php-fpm/php-fpm-user-pools/).
Easy PHP-FPM Configuration with cPanel & WHM PHP-FPM gives busy web servers a huge performance boost. Just as important, it helps web hosts to make the most of limited server resources, reducing the cost of providing an excellent hosting experience to clients and their users.
With cPanel & WHM, PHP-FPM can be activated in seconds and configured in an intuitive interface. If you need to dig deeper into PHP directives, our module makes building custom configurations for the runtime and worker pools straightforward.

المرجع:
https://blog.cpanel.com/how-to-use-php-fpm-with-cpanel/