Views: 2030
Last Modified: 15.09.2022

Expedite cache handling

Attention! Below are the actions that may be categorized as an 'extreme' tuning. Such actions require a high level of competency and qualifications from system administrator, with clear understanding of performed actions.

Using the connection via unix socket to local memcache servers, expediting project operation. The kernel ensures cache validity on all nodes, deleting marked cache keys. Such cluster work mode has proven itself very well in various load tests and actual operation, ensuring around 30% growth due to faster cache handling.

Local cache mode setup

For example, there are two nodes with configured web server roles, memcache and database. In this case, you need to execute the following steps:

  1. Configure memcache for the use of web socket and the Web Cluster module for handling memcache via the socket.
    • To configure memcache for the socket, execute the command as follows:
      cat /etc/sysconfig/memcached 
      # Ansible managed: /etc/ansible/roles/memcached/templates/sysconfig-memcached.j2 modified on 2015-01-30 19:00:16 by root on bx24.perf
      # memcached settings
      PORT="11211"
      USER="memcached"
      MAXCONN="4096"
      CACHESIZE="512"
      OPTIONS="-t 8 -s /tmp/memcached.sock -a 0777"
    • To configure the Web Cluster module for handling memcache via socket indicate If the project plans to use memcached, you need to configure it according to the projected load.

      Learn more ...
      port 0 and the URL unix:///tmp/memcached.sock
  2. In the cluster module, add Groups is an entity created for convenience only. They are used for merging "nodes" within a geo cluster. This allows locating your own: database servers, Memcached-servers and web servers inside data centers with various geographic locations.

    Learn more ...
    the required number of groups.
  3. Define the constants identifying group ID as well as slave reading mode for any group on each server.
    <?
    define('BX_CLUSTER_GROUP', 1);
    define('BX_CLUSTER_SLAVE_USE_ANY_GROUP', true);
    ?>
  4. Move the server's slave to the Bitrix Site Manager admin section, assorted by different groups. For moving the server slave to a required group you need to edit corresponding records in the table b_cluster_dbnode, by specifying a required value to the GROUP_ID field.
  5. For moving memcached servers to a required group, you need to indicate a required value of the GROUP_ID key in the file /bitrix/modules/cluster/memcache.php.

After this, servers will start working with the local cache via socket, which is significantly faster than handling remote servers via TCP.


0


Courses developed by Bitrix24