• Resolved dfbfsndsngr

    (@dfbfsndsngr)


    Hello,

    My problem:
    on my webserver I see many “php-fpm” processes running ~50 processes at a time.
    (Traffic is also high)

    When i load a page on my website the page seems to be loaded from WP Super Cache path.
    (I add a Header after “try_files” and the site source code has the WP Super Cache Comment at the end of the page)

    My Questions:
    Why are there many php-fpm processes?
    (In my opinion everything should be loaded immediately from cache and therefore not many processes should be running)
    Is the problem with WP Super Cache settings, nginx setting or something else?

    Also i am not a professional and i am learning by doing.

    Server: VPS, RAM 64 GB, 8 cores (Server itself should not be problem i think)
    I am also using plesk

    My nginx config looks like this:

    #Permalink fix für Nginx Only + Check in cache for entry
    
    # WP Super Cache rules.
    # Designed to be included from a 'wordpress-ms-...' configuration file.
    
    set $cache_uri $request_uri;
    
    # POST requests and urls with a query string should always go to PHP
    if ($request_method = POST) {
    	set $cache_uri 'null cache';
    }
    
    if ($query_string != "") {
    	set $cache_uri 'null cache';
    }
    
    # Don't cache uris containing the following segments
    if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
    	set $cache_uri 'null cache';
    }
    
    # Don't use the cache for logged in users or recent commenters
    if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
    	set $cache_uri 'null cache';
    }
    
    location / {
    	gzip  on;
    	gzip_http_version 1.0;
    	gzip_vary on;
    	gzip_comp_level 3;
    	gzip_proxied any;
    	gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    	gzip_buffers 16 8k;
    	#try_files /wp-content/cache/supercache/${http_host}${request_uri}index-https.html $uri $uri/ /index.php?$args;
    	try_files /wp-content/cache/supercache/${http_host}${cache_uri}index-https.html $uri $uri/ /index.php?$args;
    	#try_files "/wp-content/cache/supercache/$http_host/$request_uri/index-https.html" $uri $uri/ /index.php?$args;
    	add_header "X-Cache" "HIT - WP Super Cache";
    }
    
    pagespeed on;
    pagespeed FileCachePath "/var/cache/pagespeed/";
    pagespeed FileCacheSizeKb            1638400;
    pagespeed FileCacheCleanIntervalMs   172800000;
    pagespeed FileCacheInodeLimit        500000;
    
    pagespeed Domain *.blackout-news.de;
    pagespeed Domain https://blackout-news.de;
    pagespeed Domain https://blackout-news.de;
    
    pagespeed Disallow "*/wp-admin/*";
    pagespeed Disallow "*/tinymce/*";
    pagespeed Disallow "*/mysql/*";
    
    pagespeed Statistics on;
    pagespeed StatisticsLogging on;
    pagespeed LogDir /var/log/pagespeed;
    pagespeed StatisticsLoggingIntervalMs 60000;
    pagespeed StatisticsLoggingMaxFileSizeKb 1024;
    location /ngx_pagespeed_statistics {
    	allow xxx;
    	deny all;
    }
    location /ngx_pagespeed_message {
    	allow xxx;
    	deny all;
    }
    location /pagespeed_console {
    	allow xxx;
    	deny all;
    }
    location ~ ^/pagespeed_admin {
    	allow xxx;
    	deny all;
    }
    pagespeed StatisticsPath /ngx_pagespeed_statistics;
    pagespeed MessagesPath /ngx_pagespeed_message;
    pagespeed ConsolePath /pagespeed_console;
    pagespeed AdminPath /pagespeed_admin;
    
    pagespeed LoadFromFile "https://blackout-news.de/wp-content/" "/var/www/vhosts/blackout-news.de/httpdocs/wp-content/";
    pagespeed LoadFromFile "https://blackout-news.de/wp-content/" "/var/www/vhosts/blackout-news.de/httpdocs/wp-content/";
    
    pagespeed LoadFromFile "https://blackout-news.de/wp-includes/" "/var/www/vhosts/blackout-news.de/httpdocs/wp-includes/";
    pagespeed LoadFromFile "https://blackout-news.de/wp-includes/" "/var/www/vhosts/blackout-news.de/httpdocs/wp-includes/";
    
    pagespeed MemcachedServers "localhost:11211";
    pagespeed MemcachedTimeoutUs 1000000;
    
    pagespeed RewriteLevel CoreFilters;
    pagespeed CriticalImagesBeaconEnabled false;
    pagespeed DisableFilters lazyload_images;
    pagespeed DisableFilters inline_preview_images;
    pagespeed DisableFilters inline_images;
    pagespeed DisableFilters prioritize_critical_css;
    
    pagespeed SlowFileLatencyUs 500000;
    
    location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
    	add_header "" "";
    }
    location ~ "^/pagespeed_static/" { }
    location ~ "^/ngx_pagespeed_beacon$" { }
    
    #Browser Cache
    location ~* \.(webp|js|jpg|jpeg|gif|png|css|tgz|gz|rar|bz2|doc|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|woff|woff2|svg)$ {
    	expires 30d;
    	add_header Pragma "public";
    	add_header Cache-Control "public";
    }
    
    location = /xmlrpc.php {
    	deny all;
    }
    • This topic was modified 2 years, 10 months ago by dfbfsndsngr.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Unfortunately I don’t have an Nginx install to test this on – every time I tried setting it up something would go wrong. I can’t tell you why there are lots of php-fpm processes.
    Have you enabled debugging in the plugin to verify that it’s working correctly? I guess that PHP is being used to serve the cache files which explains why there are PHP processes, but they should be served very quickly. Do you have any sort of keep-alive setting enabled that would keep a process connected to a remote visitor browser?

    Thread Starter dfbfsndsngr

    (@dfbfsndsngr)

    Hey,

    I found the Problem.

    if ($query_string != “”) {
    set $cache_uri ‘null cache’;
    }

    This prevents all requests with query strings being served cached version.
    I had a a lot of traffic from facebook so a lot of requests were sent to php-fpm and not served from cache.
    Links from facebook add arguments to the link in this format:
    https://www.example.com/?fbclid=xxxxxxxxxx

    All tests I did with my website did not include query strings. Therefore I only saw cashed pages.

    My solution to this:

    if ($request_uri ~ “([^\?]*)\?(.*)fbclid=([^&]*)&?(.*)”) {
    set $cache_uri $1;
    }

    It removes all query strings from variable “cached_uri” if the expression “fbclid” is present.

    • This reply was modified 2 years, 10 months ago by dfbfsndsngr.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘NGINX and WP Super Cache: Many php-fpm processes with active cache’ is closed to new replies.