Optimizing Bitrix CMS Performance

If you're considering enhancing the performance of your CMS Bitrix-based site, the first step is to migrate your site to a Bitrix7 server. Creating a server with the Bitrix7 system is available through your control panel.

You can perform the migration yourself or use our specialists’ assistance.

CMS Configuration

After migrating the site, you can start configuring the CMS.

  1. Ensure that the "System Check" section doesn’t have any error records.
  2. Check the "Performance Dashboard" in the "Bitrix" tab. Here, the value should be set to "Bitrix (optimal)."
  3. Change the database table type to InnoDB and optimize the database. To start, create a data backup.

Server Configuration

Next, let's move on to server configuration.

  1. Connect to the server via SSH using the root user credentials.
  2. Launch the Bitrix virtual environment menu with the following command:
  1. Select option 4, "Configure memcached servers."
  2. It will start the installation of memcached. During the installation, you'll need to specify your server's hostname. Enter the value for ServerName displayed in the table on the screen.
  3. After the installation, configure the /etc/sysconfig/memcached configuration file.

Open the file in a text editor, for instance, using nano:

nano /etc/sysconfig/memcached

If nano is not available, you can install it using the command yum install nano, or use another editor already installed on the server, like vim.

Set the following parameters:

# Maximum number of concurrent connections (default is 1024)
MAXCONN = "1024"

# Memory allocated for cache (default is 64MB)
CACHESIZE = "1024"

# Number of memcached threads
OPTIONS = "-t 4"

Save the changes you've made.

  1. Restart the service with the following command:
systemctl restart memcached.service
  1. In the /bitrix/php_interface/dbconn.php file, add a connection to memcached. Execute the following command:
nano /path_to_site_directory/bitrix/php_interface/dbconn.php

Replace path_to_site_directory with the correct path for your system and add the following parameters to the file:

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

Save the changes you've made.

  1. Open the /bitrix/.settings_extra.php file (if the file doesn’t exist, execute the same command to create it):
nano /path_to_site_directory/bitrix/.settings_extra.php

Add the following parameters to the file:

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

Save the changes you've made.

Please note that misconfiguring memcached might negatively impact performance. If you notice a performance drop, you can experiment with values in the /etc/sysconfig/memcached configuration file, as configured in step 5.

  1. To improve the site's performance, besides enabling memcached, you can move the MySQL temporary file directory to a RAM disk.

To perform this operation, follow these steps:

9.1. Create a directory for temporary files, for example, /var/lib/mysql/tmp:

mkdir /var/lib/mysql/tmp

9.2. Change the owner and group of the directory to mysql:

chown mysql:mysql /var/lib/mysql/tmp

9.3. Identify the user ID (uid) and group ID (gid) for mysql:

id mysql

9.4. Edit the /etc/fstab file:

nano /etc/fstab

Append a line at the end of the file specifying the values obtained in the previous step:

tmpfs /var/lib/mysql/tmp tmpfs rw,gid=27,uid=27,size=1G,nr_inodes=10k,mode=0700 0 0

The size parameter value should be set depending on the available RAM.

9.5. Mount the new tmpfs partition:

mount /var/lib/mysql/tmp

9.6. Make changes to the MySQL configuration file /etc/mysql/my.cnf and add the following line:


9.7. Restart the MySQL service:

systemctl restart mysqld
  1. Include a parameter in the file /etc/mysql/conf.d/z_bx_custom.cnf:
innodb_flush_log_at_trx_commit = 0

This parameter allows the use of deferred transactions.

Have more questions about Hosting?