{"id":1992,"date":"2022-08-30T15:21:09","date_gmt":"2022-08-30T15:21:09","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/08\/why-is-php-fpm-only-using-one-process-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:21:09","modified_gmt":"2022-08-30T15:21:09","slug":"why-is-php-fpm-only-using-one-process-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/why-is-php-fpm-only-using-one-process-collection-of-common-programming-errors\/","title":{"rendered":"Why Is PHP-FPM Only Using One Process?-Collection of common programming errors"},"content":{"rendered":"<p>Looking at my PHP-FPM stats page, it looks like only one process is handling all of the connections right now.<\/p>\n<p>My guess is that requests are being executed so quickly, thus far, that it doesn&#8217;t need to use another process yet. Would this be the case?<\/p>\n<p>Here&#8217;s what I&#8217;m seeing in my PHP-FPM stats page:<\/p>\n<pre><code>pool                    www\nprocess manager         static\nstart since             432796\naccepted conn           90399\nlisten queue            0\nmax listen queue        1\nlisten queue len        128\nidle processes          63\nactive processes        1\ntotal processes         64\nmax active processes    6\nmax children reached    0\n<\/code><\/pre>\n<p>This is what my PHP-FPM Config looks like:<\/p>\n<pre><code>[General]\n pid = \/var\/run\/php5-fpm.pid\n error_log = \/var\/log\/php5-fpm.log\n syslog.ident = php-fpm\n syslog.facility = 24\n log_level = unknown value\n emergency_restart_interval = 0s\n emergency_restart_threshold = 0\n process_control_timeout = 0s\n process.max = 0\n process.priority = undefined\n daemonize = yes\n rlimit_files = 30000\n rlimit_core = 0\n events.mechanism = epoll\n\n[www]\n prefix = undefined\n user = www-data\n group = www-data\n listen = 127.0.0.1:9000\n listen.backlog = 128\n listen.owner = undefined\n listen.group = undefined\n listen.mode = undefined\n listen.allowed_clients = 127.0.0.1\n process.priority = undefined\n pm = static\n pm.max_children = 64\n pm.start_servers = 8\n pm.min_spare_servers = 4\n pm.max_spare_servers = 10\n pm.process_idle_timeout = 10\n pm.max_requests = 12800\n pm.status_path = \/fpm\n ping.path = undefined\n ping.response = undefined\n access.log = undefined\n access.format = undefined\n slowlog = \/var\/log\/www.log.slow\n request_slowlog_timeout = 5s\n request_terminate_timeout = 120s\n rlimit_files = 30000\n rlimit_core = 0\n chroot = undefined\n chdir = \/\n catch_workers_output = yes\n security.limit_extensions = .php .phar\n<\/code><\/pre>\n<ol>\n<li>\n<blockquote>\n<p>Why Is PHP-FPM Only Using One Process?<\/p>\n<\/blockquote>\n<p>Because&#8230; 1 is enough. But it doesn&#8217;t mean that the number of active processes always is 1.<\/p>\n<p>Split the terminal into 2 regions: in the first one type:<\/p>\n<pre><code>$ watch 'lynx -dump http:\/\/domain.com\/fpm'\n<\/code><\/pre>\n<p>and in the second one, try something like this:<\/p>\n<pre><code>$ ab -c 1000 -n 10000 http:\/\/domain.com\/fpm\n<\/code><\/pre>\n<p>then see what&#8217;s going on in the first region:<\/p>\n<pre><code>pool:                 www\nprocess manager:      dynamic\nstart time:           04\/Sep\/2012:23:19:24 +0700\nstart since:          3441\naccepted conn:        42296\nlisten queue:         0\nmax listen queue:     8\nlisten queue len:     128\nidle processes:       18\nactive processes:     3\ntotal processes:      21\nmax active processes: 21\nmax children reached: 0\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-12-08 05:39:48. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Looking at my PHP-FPM stats page, it looks like only one process is handling all of the connections right now. My guess is that requests are being executed so quickly, thus far, that it doesn&#8217;t need to use another process yet. Would this be the case? Here&#8217;s what I&#8217;m seeing in my PHP-FPM stats page: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1992","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1992","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1992"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1992\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1992"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1992"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1992"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}