Bitrix24. Playing with the settings and optimizing the project

In this article we will tell you how to optimize a large project in Bitrix24 and increase its performance by 3 times by changing the MySQL settings and the CPU power mode.



Given



Corporate portal in Bitrix24, designed for several hundred users, with ~ 300 GB of files and ~ 80 GB of database on a dedicated server with BitrixVM.



Before changing the settings, the indicators were as follows:







Standard performance test in the Bitrix admin panel.



Of all the parameters, you should pay special attention to working with MySQL and PHP Configuration. These indicators are especially important for us, as they indirectly reflect the level of project performance.



Client request



Our client wanted to not only move the project to a new dedicated server, but also improve performance parameters. For example, difficulties include the inability to dump the database on the source server, and the slow operation of the portal itself.



Decision



MySQL settings are the first thing we start working with.



Let's replace the standard values โ€‹โ€‹of BitrixVM with:



explicit_defaults_for_timestamp = 1
expire_logs_days = 10
max_binlog_size = 100M
max_allowed_packet = 128M
transaction-isolation = READ-COMMITTED
performance_schema = OFF
sql_mode = ""


# Cache parameters
query_cache_type = 1
query_cache_size=16M
query_cache_limit=4M
key_buffer_size=256M
join_buffer_size=2M
sort_buffer_size=4M

# Parameters for temporary tables
tmpdir = /tmp
tmp_table_size=128M
max_heap_table_size=128M
thread_cache_size = 4
table_open_cache = 2048

# InnoDB parameters
innodb_file_per_table
innodb_buffer_pool_size = 8192M
innodb_buffer_pool_instances = 1
innodb_flush_log_at_trx_commit = 0
innodb_flush_method = O_DIRECT
innodb_strict_mode = OFF

# Database charset parameters
character-set-server=utf8
collation-server=utf8_general_ci
init-connect="SET NAMES utf8"

[mysqldump]
quick
quote-names
default-character-set = utf8
      
      





The next step is to change the CPU power mode, since Bitrix loves a higher processor frequency.



Depending on the number of cores in each change

file /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor



powersave on performance .



Next, let's check the result:







We see that the work with MySQL has changed the most: the "write" and "change" parameters have grown almost 3 times; the "reading" indicator increased 5 times. This means that when the site accesses the database, this type of operation will be performed several times faster. As a result, the overall performance of the site will also increase.



Due to the change in the CPU power mode (this is possible, since a dedicated server is used), the number of operations on the CPU has increased.



Now you need to edit the settings for OPcache.



In the file, /etc/php.d/10-opcache.ini



replace its original value with:



zend_extension=opcache.so
opcache.enable = 1
opcache.enable_cli = 1
opcache.memory_consumption = 256
opcache.max_file_size = 2M
opcache.interned_strings_buffer = 64
opcache.max_accelerated_files = 130987
opcache.fast_shutdown = 1
opcache.revalidate_freq = 1
opcache.fast_shutdown=1
opcache.save_comments=1
opcache.load_comments=1
opcache.use_cwd = 1
      
      





Note: The Bitrix test will tell you that the parameter opcache.revalidate_freq



should have a value of 0 and not 1, but it will work better with the one we specified.



The parameter itself is opcache.revalidate_freq



responsible for checking the cache: with a value of 0, it is executed every time the script is run, and with a value of 1, it is executed once per second.



After changing the settings, we check the result:







From the table it follows that the indicator of work with MySQL has grown a little more. At the same time, CPU operations and overall Bitrix performance have increased significantly due to changes in PHP settings and script caching.



Output



Thanks to such simple changes in the settings, we were able to increase the project performance by 3 times, and the interaction with the database - from 3 to 5 times (based on the overall score of the Bitrix test). Our client is completely satisfied with the work of the project on the new server. We did it!



In this optimization method, we focused on the main points with which Bitrix interacts, as well as on the test itself. Clients often pay attention to it.



Other ways to improve Bitrix performance include installing and configuring a caching service (for example, Redis). CMS performance may drop, but overall site performance should be better. In addition, you can use php-fpm, but in our case it would be irrational to remake the OS originally configured for Bitrix.



You can also play around with the MySQL settings. They are individual for each project and configuration, so there is no one perfect recipe. It will be interesting to know your life hacks for optimizing projects in Bitrix. Share your opinion in the comments.



All Articles