PHPFPM using your own status optimization steps

Source: Internet
Author: User
Tags cpu usage

PHP-FPM and Nginx have a status page built in, which is very helpful for you to understand the status of PHP-FPM and monitor php-fpm. For subsequent Zabbix monitoring, we need to understand how the PHP-FPM status page is going.

1. Enable the PHP-FPM status feature

# cat  /usr/local/php-5.5.10/etc/php-fpm.conf | grep status_pathpm.status_path = /status

2. Nginx Configuration

server {    listen  *:80 default_server;    server_name _;    location ~ ^/(status|ping)$    {        include fastcgi_params;        127.0.0.1:9000;        $fastcgi_script_name;    }}

3. Restart NGINX/PHP-FPM

service nginx restartservice php-fpm restart

4. Open the Status page

# curl http://www.ttlsa.com/statuspool:                 wwwprocess manager:      dynamicstart time:           14/May/2014:22:40:15 +0800start since:          58508accepted conn:        33listen queue:         0max listen queue:     8listen queue len:     0idle processes:       2active processes:     1total processes:      350slow requests:        2091

5. PHP-FPM Status Detailed

    • POOL–FPM pool name, mostly www
      Process manager– processes management, value: Static, dynamic or OnDemand. Dynamic
      Start time– start date, if Reload php-fpm, the time will be updated
      Start since– Run time
      Accepted conn– the number of requests accepted by the current pool
      listen queue请求等待队列,如果这个值不为0,那么要增加FPM的进程数量
      Max Listen queue– Requests the highest number of wait queues
      Listen queue len–socket wait queues length
      Idle processes– Free Process number
      Active processes– number of active processes
      Total processes– Process Quantity
      Max Active processes– maximum number of active processes (FPM start count)
      max children reached-大道进程最大数量限制的次数,如果这个数量不为0,那说明你的最大进程数量太小了,请改大一点。
      Slow requests– enabled PHP-FPM Slow-log, number of slow requests

6. PHP-FPM Other parameters

PHP-FPM Status Page One place to personalize is that it can take parameters, can take parameters, and the json xml html first three parameters can be individually and full do a combination.

    • 6.1 JSON
  # Curl HTTP/ 127.0  . 0  . 1 /status json{" pool ":   "www"  , " Process manager ":   "Dynamic"  , " Start time ":   1400078415  , " start since ":   59624  , " accepted conn ":    , " Listen queue ":   0  , " Max Listen queue ":   8  , " listen queue len ":   0  , " Idle Processes ":   2  , " Active Processes ":   1  , " Total Processes ":   3  , " Max Active Processes ":   5  , " max Children reached ":   0  , " slow requests :   2145  }  
    • 6.2 XML
# Curl Http://127.0.0.1/status?xml
    
 <status><pool>Www 
     Pool
 ><process-manager>Dynamic 
     Process-manager
 ><start-time>1400078415 
     Start-time
 ><start-since>59640 
     start-since
 ><accepted-conn>36 
     Accepted-conn
 ><listen-queue>0 
     Listen-queue
 ><max-listen-queue>8 
     Max-listen-queue
 ><listen-queue-len>0 
     Listen-queue-len
 ><idle-processes>2 
     idle-processes
 ><active-processes>1 
     active-processes
 ><total-processes>3 
     total-processes
 ><max-active-processes>5 
     max-active-processes
 ><max-children-reached>0 
     max-children-reached
 ><slow-requests>2145 
     slow-requests
 >
    • 6.3 HTML
# Curl Http://127.0.0.1/status?html<htmlxmlns="http://www.w3.org/1999/xhtml"xml:lang="en "lang=" en "><head><title>PHP-FPM Status Page 
     title
 > 
     Head
 ><body><table><tr><th>Pool 
     th
 ><TD>Www 
     TD
 > 
     TR
 ><tr><th>Process Manager 
     th
 ><TD>Dynamic 
     TD
 > 
     TR
 ><tr><th>Start time 
     th
 ><TD>14/may/2014:22:40:15 +0800 
     TD
 > 
     TR
 ><tr><th>Start since 
     th
 ><TD>59662 
     TD
 > 
     TR
 ><tr><th>Accepted Conn 
     th
 ><TD>8 
     TD
 > 
     TR
 ><tr><th>Listen queue 
     th
 ><TD>0 
     TD
 > 
     TR
 ><tr><th>Max Listen queue 
     th
 ><TD>8 
     TD
 > 
     TR
 ><tr><th>Listen Queue Len 
     th
 ><TD>0 
     TD
 > 
     TR
 ><tr><th>Idle processes 
     th
 ><TD>2 
     TD
 > 
     TR
 ><tr><th>Active processes 
     th
 ><TD>1 
     TD
 > 
     TR
 ><tr><th>Total Processes 
     th
 ><TD>3 
     TD
 > 
     TR
 ><tr><th>Max Active Processes 
     th
 ><TD>5 
     TD
 > 
     TR
 ><tr><th>Max Children reached 
     th
 ><TD>0 
     TD
 > 
     TR
 ><tr><th>Slow requests 
     th
 ><TD>2147 
     TD
 > 
     TR
 > 
     Table
 > 
     Body
 > 
     HTML
 >
    • 6.4 Full
  # Curl Http://127.0.0.1/status?fullpool:wwwprocess Manager:         Dynamicstart time:14/may/2014:22:40:15 +0800start since:59695accepted conn:1listen queue:      0max Listen queue:8listen queue len:0idle processes:2active processes:1total processes: 3max Active Processes:5max Children Reached:0slow requests:2148************************pid:29             050state:idlestart time:15/may/2014:15:09:32 +0800start since:338requests:                 62request duration:1025585request method:getrequest URI:/index.phpcontent length:0user: -script:/data/site/www.ttlsa.com/index.phplast request Cpu:45.83last Request memory:249 03680 .... omit several pid ....  
    • 6.5 Full explanation
    • pid– process PID, you can kill this process alone. You can use this PID to kill a long running process.
      state– status of the current process (Idle, Running, ...)
      Start time– The date the process started
      Start since– Current process run time
      requests– how many requests are processed by the current process
      Request duration– requested length (subtle)
      Request method– Method (GET, POST, ...)
      Request uri– Requests URI
      Content length– Request Contents Length (POST only)
      user– User (Php_auth_user) (or '-' if not set)
      script–php script (or '-' if not set)
      Last request cpu– CPU usage.
      Last request Memorythe-memory used by previous requests

7. Complete

The PHP-FPM Status page is very useful, and using either Zabbix or Nagios monitoring can consider using XML or the default method. Using the web, it is recommended to use HTML, the table will be more clear.

The above describes the PHPFPM use of the status optimization steps, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.