1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Zend Opcache & FastCGI

Discussion in 'Server Configuration and Hosting' started by Solidus, Jan 2, 2015.

  1. Solidus

    Solidus Well-Known Member

    Since switching to fCGI instead of Apache handler to make things easier with permissions, Zend Opcache is caching things differently.
    When using Apache handler, the cached scripts would continue to increase and so would cache hits (this could reach hundreds of millions).
    Using fCGI, cached scripts seem to reset and cache hits also drop to 0 and increases again. You can see here,


    Refreshing 2 minutes later,


    Is this intended behaviour?
    Thank you.
  2. Da Bookie Mon

    Da Bookie Mon Well-Known Member

    Give Memcache a try. I like it far better then Opcache using FastCGI
  3. Xon

    Xon Well-Known Member

    @Solidus have a look ta the number of restarts. It is by design that the cache recycles itself if it gets too full.

    You can try increasing how many slots the opcache has, or memory being used.

    Going by the monitoring tool, he is only using it for opcode caching. Memcache can't be used for that (it caches variable data)
  4. Solidus

    Solidus Well-Known Member

    I use memcached with opcache.
    The cache doesn't even get close to full, barely 5% of the 1.5gb allocated to it is used when the cache resets.
  5. SimonV

    SimonV Well-Known Member

    Im having a similar issue, are you running 'mod_fastcgi' or 'mod_fcgid'?
  6. shimabuku

    shimabuku Member

    I am also experiencing this similar issue. I am running mod_fcgid.
  7. Solidus

    Solidus Well-Known Member

    mod_fastcgi for me.
  8. Solidus

    Solidus Well-Known Member

    Still haven't seen any bug reports or fixes posted on the interwebs.
  9. Moscato

    Moscato Active Member

    This may seem a little extreme and not a direct solution, but have you considered apache 2.4 and fastcgi php-fpm?
  10. Gene Steinberg

    Gene Steinberg Well-Known Member

    This may be a dead thread, but i wanted to resurrect it. I am trying PHP-FPM on a Plesk server. It does work very well with Opcache, but we have a problem that prevents its use.

    Our webmaster set up a small set of PHP code that works with our premium podcast service, which is configured as a member upgrade in XenForo using Resource Manager. Well, the PHP code provides a special authenticated RSS feed. But when I switch from FastCGI to PHP-FPM, it breaks the login sequence. I keep getting the login prompt.

    Anyone who can help me fix this PHP code can contact me privately and I'll send the code.
  11. Moscato

    Moscato Active Member

    Fastcgi is used for php-fpm so its not something you can switch from and to
  12. Gene Steinberg

    Gene Steinberg Well-Known Member


    I had to change our PHP code and add a special Apache header to make this work with PHP-FPM. Plesk 12.5.x offers FastCGI w/Apache, PHP-FPM w/Apache, and PHP-FPM with nginx.

    The one in the middle, when I got it properly configured with the help of a friendly support rep from Parallels on his own time, produces noticeably spiffier performance on all my sites because it works more efficiently with Zend Opcache. With FastCGI, the cached content is constantly dumped, so performance isn't as good.
    Solidus likes this.
  13. Solidus

    Solidus Well-Known Member

    Good to know. Upgrading to Plesk 12.5 myself soon.
  14. Moscato

    Moscato Active Member

    "Plesk 12.5.x offers FastCGI w/Apache, PHP-FPM w/Apache, and PHP-FPM with nginx."
    FastCGI isn't a PHP processor, it's a protocol to transmit requests. That's like saying that you generated a html page using HTTP. It doesn't make sense.

    FastCGI can't process PHP code. It's not a PHP processor. It's a protocol used to pass requests to language processors, which in the case of PHP, would be PHP-FPM.

    Nginx nor Apache can use php-fpm on its own, it uses a fastcgi module to make requests to php-fpm.

    location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
    return 404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;

    Here is an example of fastCGI php-fpm being implemented in nginx.
    Notice it uses both fastcgi and php-fpm. That's because it's using fastcgi to pass the call to php-fpm.

Share This Page