Join the community today
Register Now

Memcached Memcached benefits???

Discussion in 'Other Centmin Mod Installed software' started by anthony parsons, Aug 1, 2018.

  1. anthony parsons

    anthony parsons Premium Member Premium Member

    79
    20
    8
    Feb 12, 2017
    Ratings:
    +24
    Local Time:
    5:43 PM
    1.22.0
    10.4.26
    If memory serves me correctly, there is no benefit in memcached on a single server. Is that still correct?


    If so, is it running by default? And if so, to disable?
     
  2. eva2000

    eva2000 Administrator Staff Member

    55,801
    12,271
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,857
    Local Time:
    5:43 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Memcached runs by default but isn't used until you configure your web apps to use it. There's still a benefit always whether local or remote but ultimately depends on how memcached is used i.e. Offloading to memcached to reduce php and/or mysql load. To disable see Memcached Server - CentminMod.com LEMP Nginx web stack for CentOS
     
  3. anthony parsons

    anthony parsons Premium Member Premium Member

    79
    20
    8
    Feb 12, 2017
    Ratings:
    +24
    Local Time:
    5:43 PM
    1.22.0
    10.4.26
    Do you have recommended settings for XF, or just use the default XF ones? If you say there is a benefit, I will give it a test to see for myself.

    Code:
    $config['cache']['backend'] = 'Memcached';
    $config['cache']['backendOptions'] = array(
        'compression' => false,
        'servers' => array(
            array(
                // your memcached server IP /address
                'host' => 'localhost',
              
                // memcached port
                'port' => 11211,
            )
        )
    );
    Do you bother with the XF frontend cache? Purely just curious as we're talking about caches...

    Code:
    $config['cache']['enabled'] = true;
    $config['cache']['frontend'] = 'Core';
    $config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';
     
  4. anthony parsons

    anthony parsons Premium Member Premium Member

    79
    20
    8
    Feb 12, 2017
    Ratings:
    +24
    Local Time:
    5:43 PM
    1.22.0
    10.4.26
    And XF2 is just:

    Code:
    $config['cache']['enabled'] = true;
    $config['cache']['provider'] = 'Memcached';
    $config['cache']['config'] = [
        'server' => '127.0.0.1'
    ];
    
     
  5. eva2000

    eva2000 Administrator Staff Member

    55,801
    12,271
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,857
    Local Time:
    5:43 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Are you using XF 2 or XF 1.. I haven't looked at XF 2 since the betas Xenforo - Xenforo 2.0.0 Beta 1 Released.

    For XF 1 it was, for Xenforo 1.5.x caching, PHP 5.6+ has Zend Opcache for opcode caching which is automatic so nothing to configure. For backend caching for Centmin Mod Memcached server is already installed by Centmin Mod

    Xenforo Libmemcached/Memcached server backend cache



    For Centmin Mod LEMP web stack powered Xenforo forum which has Libememcach/Memcached PHP extension and Memcached server installed out of the box.

    As per official Xenforo manual, within your Xenforo library/config.php add or alter settings to the following, caching the cache_id_prefix value from xfxx_ to a unique one to each Xenforo installed instance on your server. So your library/config.php would have something like
    PHP:
    $config['cache']['enabled'] = true;
    $config['cache']['cacheSessions'] = true;
    $config['cache']['frontend'] = 'Core';
    $config['cache']['frontendOptions'] = array(
    'caching' => true,
    'cache_id_prefix' => 'xfxx_',
    'automatic_serialization' => false,
    'lifetime' => 0
    );

    $config['cache']['backend'] = 'Libmemcached';

    $config['cache']['backendOptions'] = array(
    'servers' => array(
    array(
    'host' => '127.0.0.1',
    'port' => 11211,
    'weight' => 1
    )
    )
    );
    libmemcached is supported by Zend Framework XF 1.5 used Manual - Documentation - Zend Framework
    but not sure on XF2 so XF2 has Cache support - XenForo 2 Manual
    zend cache backend = Memcached uses memcache php pecl extension while zend cache backend Libmemcached uses memcached php pecl extension. Centmin Mod installs both memcache and memcached php pecl extensions though PHP 7.3 doesn't support memcache php pecl extension anymore
     
    Last edited: Aug 2, 2018
  6. anthony parsons

    anthony parsons Premium Member Premium Member

    79
    20
    8
    Feb 12, 2017
    Ratings:
    +24
    Local Time:
    5:43 PM
    1.22.0
    10.4.26
    Main site, XF1, but that is about to be XF2. New site I have also setup, XF2.

    Cache support - XenForo 2 Manual

    Says you can configure an array of servers, but that doesn't really apply does it on a single server?
     
  7. eva2000

    eva2000 Administrator Staff Member

    55,801
    12,271
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,857
    Local Time:
    5:43 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  8. anthony parsons

    anthony parsons Premium Member Premium Member

    79
    20
    8
    Feb 12, 2017
    Ratings:
    +24
    Local Time:
    5:43 PM
    1.22.0
    10.4.26
  9. anthony parsons

    anthony parsons Premium Member Premium Member

    79
    20
    8
    Feb 12, 2017
    Ratings:
    +24
    Local Time:
    5:43 PM
    1.22.0
    10.4.26
    Linked that into your thread.
     
  10. Andy

    Andy Active Member

    544
    89
    28
    Aug 6, 2014
    Ratings:
    +133
    Local Time:
    2:43 AM
    what is the optimal setting for centminmod running xf2 then
    do we need session cache?
    i see George saying something about 'memcached.hostname.com' but do we have to actually setup the subdomain memcached to be able to use it?
    at the moment, i have this on my config file which is from default xf2 document
    Code:
    $config['cache']['enabled'] = true;
    $config['cache']['provider'] = 'Memcached';
    $config['cache']['config'] = [
        'server' => '127.0.0.1'
    ];
     
  11. eva2000

    eva2000 Administrator Staff Member

    55,801
    12,271
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,857
    Local Time:
    5:43 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  12. Andy

    Andy Active Member

    544
    89
    28
    Aug 6, 2014
    Ratings:
    +133
    Local Time:
    2:43 AM
    How do we check if memcached is actually caching xenforo files, etc?
     
  13. eva2000

    eva2000 Administrator Staff Member

    55,801
    12,271
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,857
    Local Time:
    5:43 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  14. Andy

    Andy Active Member

    544
    89
    28
    Aug 6, 2014
    Ratings:
    +133
    Local Time:
    2:43 AM
    how does it look on mine. i'm surprised there is only 8mb allocated to it and there still plenty unused.

    Screen Shot 2018-08-02 at 4.24.46 PM.png
     
  15. anthony parsons

    anthony parsons Premium Member Premium Member

    79
    20
    8
    Feb 12, 2017
    Ratings:
    +24
    Local Time:
    5:43 PM
    1.22.0
    10.4.26
    Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

    memcached - a distributed memory object caching system

    You are not storing table / rows in memcache, you are storing the calling data so it finds things faster, cached, instead of searching your table for it, is my understanding. That can take 50-100ms or so from a page render if data is retrieved faster.

    You will see the best gains where using a separate database server.
     
  16. eva2000

    eva2000 Administrator Staff Member

    55,801
    12,271
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,857
    Local Time:
    5:43 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    If you click on view host stats link in memcached stats page you can drill down to the key-value data to see what is being cached. For Xenforo and vBulletin default memcached cached data is very little - it isn't about how much is being cached but what is being cached - usually if you have high traffic site in the past, offloading database queries to memcached caching server had huge positive impact on performance. I had vBulletin forums pushing 10 billion memcached cache hits per month saving alot of load to mysql servers in the past. You can use addons like XF Dragonbyte Optimise which offload more Xenforo data to memcached or redis servers - Add DragonByte Optimise & Security Xenforo Addons