Views: 1528 (Data available since 06.02.2017)

Attention! For operations, described in this lesson, *nix-systems administration knowledge is required. Prior to starting of operations, it is recommended to perform a full ┬źBitrix Virtual Appliance┬╗ backup.

if memcached is planned to be used in the project, it is necessary to configure it in accordance with anticipated load.

For this, it is required:

  1. To specify the following parameters in the /etc/sysconfig/memcached file:
    • MAXCONN = "1024" - quantity of simultaneous connections (1024 by default);
    • CACHESIZE="1024" - volume of memory, allocated for cache (64MB by default);
    • OPTIONS="t 8" - quantity of memcached flows (4 by default).

    Note: MAXCONN, CACHESIZE and OPTIONS parameters are selected experimentally depending on the type of load and on the available resources.

    The volume of memory required for caching (parameter CACHESIZE) can be evaluated according to the size of your file cache. If file cache occupies 3GB in your project, then the use of memcached with 256MB memory will not be effective due to frequent preemption.

  2. After configuring is competed, it is necessary to restart memchached via the command:

    CentOS 6:

    service memcached restart
    

    CentOS 7:

    systemctl restart memcached.service
    
  3. Next, connect it into /bitrix/php_interface/dbconn.php:

    define("BX_CACHE_TYPE", "memcache");
    define("BX_CACHE_SID", $_SERVER["DOCUMENT_ROOT"]."#01");
    define("BX_MEMCACHE_HOST", "127.0.0.1");
    define("BX_MEMCACHE_PORT", "11211");
    

    and in the file /bitrix/.settings_extra.php (create it, if unavailable):

    <?php
    return array(
      'cache' => array(
        'value' => array(
          'type' => 'memcache',
          'memcache' => array(
            'host' => '127.0.0.1',
            'port' => '11211',
          ),
          'sid' => $_SERVER["DOCUMENT_ROOT"]."#01"
        ),
      ),
    );
    ?>
    

If one more server is used, then the operation with memcached via socket can be configured to improve the productivity:

  1. Set parameters in the file /etc/sysconfig/memcached:

    • USER="bitrix" - user from which memcached will be launched;
    • OPTIONS="-t 8 -s /tmp/memcached.sock" - quantity of flows and path to socket.

  2. Restart memcached via command:

    CentOS 6:

    service memcached restart
    

    CentOS 7:

    systemctl restart memcached.service
    
  3. After that, it is necessary to modify settings in /bitrix/php_interface/dbconn.php:

    define("BX_CACHE_TYPE", "memcache");
    define("BX_CACHE_SID", $_SERVER["DOCUMENT_ROOT"]."#01");
    define("BX_MEMCACHE_HOST", "unix:///tmp/memcached.sock");
    define("BX_MEMCACHE_PORT", "0");
    

    and in the file /bitrix/.settings_extra.php (create it, if unavailable):

    <?php
    return array(
      'cache' => array(
        'value' => array(
          'type' => 'memcache',
          'memcache' => array(
            'host' => 'unix:///tmp/memcached.sock',
            'port' => '0',
          ),
          'sid' => $_SERVER["DOCUMENT_ROOT"]."#01"
        ),
      ),
    );
    ?>
    




Courses developed by «Bitrix», Inc.