Views: 272
Last Modified: 18.10.2022

  RAM cache

memcached server is a server that allows saving cache in RAM instead of files. Memcached can be used for session storage.

Advantages of employing memcached servers:

  • increased system fail-safety and reliability due to available caching subsystem,
  • increased effectiveness due to centralized use of cache by the web app,
  • unlimited scalability due to new add-on memcached servers.

In the event when all memcache server have failed to operate correctly, the caching subsystem renews the use of file cache It's recommended to delete the deprecated cache bitrix\cache bitrix\stack_cache to return to the file-based cache. .

Attention! You will beed to have an installed memcache PHP extension.

Some versions of the memcache extension may cause an error that will significantly reduce the performance when using more than one connection. You can view the performance evaluation at the performance panel before and after adding a connection. In case of a significant difference, try to install another version of memcache extension.

If you use several memcache servers, specify the variable memcache.hash_strategy string in consistent (its disabled by default). Such value is needed for the following: if one of memcaches malfunctions, a resource-consuming keys exchange will start between the memcaches, slowing down the web cluster operation. But, setting the consistent prevents such issue.


  Connecting memcached servers

Servers are connected at the page Memcached Connections (Settings > Web Cluster > [group_name] > Memcached):

  • Click the button Add at the context panel and in the form Memcached Server Connection Parameters Usually, memcached port is equal 11211

    indicate the server port and address.

    Note: when using Load, % (0..100).

  • After successful connection, server won't be active by default.

  • To launch it, select the item Use memcached.

Now the server is employed instead of file cache:

Note: memcached server settings are stored in the file \bitrix\modules\cluster\memcache.php. Accordingly, any updates of connection settings will be automatically applied to the other cluster nodes with the configured file sync in cluster.

  Config recommendations

When configuring the cluster caching subsystem, pay special attention to the parameter: get_hits: #count# (#hitrate#%) where, #hitrate# shows caching effectiveness. This value must be adjusted most closely to 100%.

You may experiment with adjusting the effectiveness, by gradually increasing the volume of memory, dedicated to a memcached server (limit_maxbytes). Start with the memory volume 128MB and gradually increase with each step having extra 32MB, until #hitrate# stops to increase significantly.

Also, it's recommended to periodically analyze the app cache use (parameter using_bytes).

The memcached server uses the LRU algorithm and stores only the most recent data in cache, with the oldest data being removed. This won't allow for the cache volume to infinitely expand in size, leading to ineffective use of the system resources and negatively impact the cache processing speed due to its size. As the result, the web cluster cache will be automatically supported the most effective state in terms of access speed and resource use.


0


Courses developed by Bitrix24