Home Backend Development PHP Tutorial 使用php-fpm状态页观察当前的php-fpm状态

使用php-fpm状态页观察当前的php-fpm状态

Jun 23, 2016 pm 01:51 PM
php-fpm state observe

    对于php-fpm的参数设置,很多情况下有这样的疑问,就是内置的几个参数例如pm.max_children,pm.start_servers等这几个参数到底该设置最多为多少才合适。其实这几个参数往往取决于当前的连接数情况,而大多数情况下,我们很难断定当前的连接数情况对于我们的pm等几个参数是否合适。所以借助于php-fpm状态页可以很方便的告诉我们这几个参数的设置是否合适。

    要开启php-fpm的状态页其实很简单在nginx的配置文件中加入:
    location /status {
            auth_basic "status page";
            auth_basic_user_file /etc/nginx/login;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
        }
    上面的auth_basic和auth_basic_user_file不是必须的,但这些都是敏感信息,一般不能让其它人看到,所以这里做了认证。在php-fpm.conf中打开:
    pm.status_path = /status
    
    然后在浏览器中打开localhost/status就可以查看到当前的状态信息了
    pool:                 www
    process manager:      dynamic
    start time:           17/Aug/2014:15:25:50 -0400
    start since:          7702
    accepted conn:        1486
    listen queue:         0
    max listen queue:     129
    listen queue len:     128
    idle processes:       9
    active processes:     1
    total processes:      10
    max active processes: 20
    max children reached: 2
    slow requests:        0

    下面介绍每个参数的作用:
    pool:php-fpm池的名称,一般都是应该是www
    process manage:进程的管理方法,php-fpm支持三种管理方法,分别是static,dynamic和ondemand,一般情况下都是dynamic
    start time:php-fpm启动时候的时间,不管是restart或者reload都会更新这里的时间
    start since:php-fpm自启动起来经过的时间,默认为秒
    accepted conn:当前接收的连接数
    listen queue:在队列中等待连接的请求个数,如果这个数字为非0,那么最好增加进程的fpm个数
    max listen queue:从fpm启动以来,在队列中等待连接请求的最大值
    listen queue len:等待连接的套接字队列大小
    idle processes:空闲的进程个数
    active processes:活动的进程个数
    total processes:总共的进程个数
    max active processes:从fpm启动以来,活动进程的最大个数,如果这个值小于当前的max_children,可以调小此值
    max children reached:当pm尝试启动更多的进程,却因为max_children的限制,没有启动更多进程的次数。如果这个值非0,那么可以适当增加fpm的进程数
    slow requests:慢请求的次数,一般如果这个值未非0,那么可能会有慢的php进程,一般一个不好的mysql查询是最大的祸首。

    如果想看到更加详细的信息,可以使用localhost/status?full查看每个子进程更加额外的信息,拿其中的一个子进程来说明:
    pid:                  6917
    state:                Idle
    start time:           17/Aug/2014:15:27:46 -0400
    start since:          8399
    requests:             35
    request duration:     69295
    request method:       GET
    request URI:          /member.php?mod=logging&action=login&infloat=yes&frommessage&inajax=1&ajaxtarget=messagelogin
    content length:       0
    user:                 -
    script:               /usr/local/nginx/html/member.php
    last request cpu:     72.16
    last request memory:  3145728
    
    这里的都比较好理解,主要看下content length和user
    content length:这里记录的是POST请求的内容长度.
    user:如果设置了PHP_AUTH_USER就会显示对于的值,否则显示为0.
    
    这里需要注意的是如果state的状态为空闲的话,那么这些相关的信息将会以最后请求的服务相关,否则信息取决于当前请求的服务.
   

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Connection status in standby: Disconnected, reason: NIC Compliance Connection status in standby: Disconnected, reason: NIC Compliance Feb 19, 2024 pm 03:15 PM

"The connection status in the event log message shows Standby: Disconnected due to NIC compliance. This means that the system is in standby mode and the network interface card (NIC) has been disconnected. Although this is usually a network issue , but can also be caused by software and hardware conflicts. In the following discussion, we will explore how to solve this problem." What is the reason for standby connection disconnection? NIC compliance? If you see the "ConnectivityStatusinStandby:DisConnected,Reason:NICCompliance" message in Windows Event Viewer, this indicates that there may be a problem with your NIC or network interface controller. This situation is usually

How to use php-fpm for high-performance tuning How to use php-fpm for high-performance tuning Jul 08, 2023 am 11:30 AM

How to use php-fpm for high-performance tuning PHP is a very popular server-side scripting language that is widely used to develop web applications and dynamic websites. However, as traffic increases, the performance of your PHP application may suffer. In order to solve this problem, we can use php-fpm (FastCGIProcessManager) for high-performance tuning. This article will introduce how to use php-fpm to improve the performance of PHP applications and provide code examples. one,

How to use PHP-FPM optimization to improve the performance of PrestaShop applications How to use PHP-FPM optimization to improve the performance of PrestaShop applications Oct 05, 2023 pm 12:33 PM

How to use PHP-FPM optimization to improve the performance of PrestaShop applications. With the rapid development of the e-commerce industry, PrestaShop has become the e-commerce platform chosen by many merchants. However, as the size of the store increases and the number of visits increases, the PrestaShop application may encounter performance bottlenecks. In order to improve the performance of the PrestaShop application, a common method is to use PHP-FPM to optimize and improve the application's processing capabilities. PHP-FPM (FastCGI

How to set Momo status How to set Momo status Mar 01, 2024 pm 12:10 PM

Momo, a well-known social platform, provides users with a wealth of functional services for their daily social interactions. On Momo, users can easily share their life status, make friends, chat, etc. Among them, the setting status function allows users to show their current mood and status to others, thereby attracting more people's attention and communication. So how to set your own Momo status? The following will give you a detailed introduction! How to set status on Momo? 1. Open Momo, click More in the lower right corner, find and click Daily Status. 2. Select the status. 3. The setting status will be displayed.

How to improve the performance of your WooCommerce application using PHP-FPM optimization How to improve the performance of your WooCommerce application using PHP-FPM optimization Oct 05, 2023 am 08:24 AM

How to Improve the Performance of WooCommerce Applications Using PHP-FPM Optimization Overview WooCommerce is a very popular e-commerce plugin for creating and managing online stores on WordPress websites. However, as your store grows and traffic increases, WooCommerce apps can become slow and unstable. To solve this problem, we can use PHP-FPM to optimize and improve the performance of WooCommerce applications. What is PHP-FP

How to check server status How to check server status Oct 09, 2023 am 10:10 AM

Methods to view server status include command line tools, graphical interface tools, monitoring tools, log files, and remote management tools. Detailed introduction: 1. Use command line tools. On Linux or Unix servers, you can use command line tools to view the status of the server; 2. Use graphical interface tools. For server operating systems with graphical interfaces, you can use the graphics provided by the system. Use interface tools to view server status; 3. Use monitoring tools. You can use special monitoring tools to monitor server status in real time, etc.

Use php-fpm connection pool to improve database access performance Use php-fpm connection pool to improve database access performance Jul 07, 2023 am 09:24 AM

Overview of using php-fpm connection pool to improve database access performance: In web development, database access is one of the most frequent and time-consuming operations. The traditional method is to create a new database connection for each database operation and then close the connection after use. This method will cause frequent establishment and closing of database connections, increasing system overhead. In order to solve this problem, you can use php-fpm connection pool technology to improve database access performance. Principle of connection pool: Connection pool is a caching technology that combines a certain number of databases

How to show up offline on WhatsApp on Android phone How to show up offline on WhatsApp on Android phone Jul 14, 2023 am 08:21 AM

Want to appear "offline" or don't want to share your current status with your friends on WhatsApp? There is a simple but clever trick to do this. You can adjust your WhatsApp settings so that your current status (offline or last seen) is not visible to your friends or others there. How to show offline status on your WhatsApp status bar? This is a very simple and streamlined process. So, follow the steps below now. Step 1 – Open WhatsApp on your phone. Step 2 – Tap ⋮ and choose to open Settings. Step 3 – Open Privacy settings to access it. Step 4 – On that privacy page, open the “Last Viewed & Online” setting to access it. Step 5 – Change the “Who can

See all articles