December 27 2022

HOW TO SPEED UP A WEBSITE ON 1C-BITRIX



Over the past three years, we have optimized the performance of many projects on 1C-Bitrix. Among them were both new sites that were hosted for the first time, and projects transferred from other hosting and corporate servers.

In this article, you will learn the basic steps that we recommend to increase the performance of the site and make it faster for visitors and search engines.

 
WHAT RESULT CAN YOU EXPECT?
If you go through these steps sequentially, you can increase the performance of even very slow sites that show 20-30 points on the Bitrix scale, up to 100 points and higher.

With the right settings, it is quite realistic to make the “slow” site “fly” and delight visitors with convenience and high speed.

So, here are 14 steps to optimize the site on 1C-Bitrix:

 
Pick up more powerful hardware on the hosting.

Use a specialized Bitrix environment.

Minimize scripts and styles.

Track and fix slow queries.

Compress images.

Postpone downloading media content.

Configure the cache lifetime.

Enable CDN.

Update the PHP version to 7.1 and higher.

Disable unnecessary modules.

Optimize database settings.

Create faceted indexes.

Enable the InnodDB table type in the database.

Configure innodb buffer pool size.

Use the memcached caching mechanism.

Enable composite mode.

For sites with a high load, consider using a server cluster.

Let's look at each of these steps in more detail.

 
Pick up more powerful hardware on the hosting
The performance of the site depends on the server capacity – the number of cores and processor frequency, the amount of RAM, the type and capacity of disks.

If you are setting up hosting for a new project, it is important to choose a server configuration that corresponds to the “voracity" of the site and the expected load level. And only then do fine-tuning based on performance monitoring.

We know that Bitrix is very sensitive to processor frequency, disk speed and memory capacity. Therefore, several ready-made configurations are provided in the Maxiplace hosting templates.  On them, most of the sites that move to us from regular hosting sites immediately begin to show higher performance.

For websites of companies and online stores with a small attendance, 1-2 processor cores, 2 GB of RAM and up to 30 GB on an SSD disk will be enough. This configuration is also suitable for those who have just launched the site and have not yet measured the traffic load.

If your site is quite “heavy”, you will need more resources. So, for sites with high traffic, as well as online stores with a large catalog of products or portals, for example, Bitrix24, we recommend using the “MIDDLE” tariff with 4 processor cores, 4 GB of RAM and 80 GB on an SSD disk.

In terms of cost, the transition from the minimum configuration to the average is comparable to the cost of one (!) small order in an online store (about 2 thousand rubles). And the result can be both an increase in orders due to the acceleration of the site, and an increase in the position of the site in the search results.

After strengthening or optimizing the hardware, we proceed to setting up the environment and the site itself.

If you are setting up hosting for a new project, it is important to choose a server configuration that corresponds to the “voracity" of the site and the expected load level. And only then do fine-tuning based on performance monitoring.

Use a specialized Bitrix server environment
We recommend using a specialized environment on the hosting – the BitrixVM virtual machine recommended by the developers of the 1C-Bitrix platform.

 
WHAT DOES THE USE OF A SPECIALIZED ENVIRONMENT GIVE?
1C-Bitrix: Virtual Machine is a virtual server, fully configured, tested and designed for optimal work with sites on 1C–Bitrix.

It already takes into account many parameters that affect performance. A set of software and a bunch of web services have already been configured to ensure optimal operation of the site on 1C-Bitrix or the Bitrix24 portal.

If you do not use the Bitrix environment, but configure the environment yourself on your VPS server, pay attention to the mode of using php as an apache module. You will see this option in the settings and can use it to speed up the work of Bitrix. At the same time, there are many nuances, since with a high load, another mode will be preferred, and you will have to involve a specialist.

Therefore, for convenience and speed of deployment, we recommend using a ready-made and repeatedly tested BitrixVM environment. We use it for all client projects on the Bitrix platform.

 
Update the PHP version to 7.X
If you installed a virtual machine more than a year ago, most likely you have one of the old versions of PHP.

You need to check the PHP version and update it to 7.x, because new versions work faster.

When the basis of the server part is configured, it's time to move on to the settings that are made from the 1C-Bitrix admin panel.

 
Minimize scripts and styles
Most of the style files and scripts are not used at the initial stage of page loading, so they should be moved to the very end. At the same time, minification and unification will reduce their weight and reduce the number of requests.

In the settings of the main module, you need to check the boxes, as shown in the screenshot below.


 

It is very important to take into account the moment when the script and style files are connected, they should be connected as follows:

// Correct

use Bitrix\\Main\\Page\\Asset;

Asset::getInstance()->addJs(SITE_TEMPLATE_PATH . "/js/main.js");

Asset::getInstance()->addCss(SITE_TEMPLATE_PATH . "/css/style.css");

This is important, because in the case of a static connection, it will not be possible to optimize the files.

 
<? //Wrong ?>

<script src="/js/main.js"></script>

<link href="/css/style.css" rel="stylesheet">

This alone can give a noticeable acceleration of loading the pages of the site.


Compress Images
The main "heavy" resource on a web page is images. The greater their weight, the slower the page loads.

For Bitrix, there is an excellent free solution for optimizing images without loss of quality. It works literally in one click.

 

Image optimization in Bitrix
Often webmasters miss image optimization, but in vain. We have had to meet sites where images of 1200x1600 are inserted into placeholders of 300x400 pixels. 

Imagine how slowly such an online store loads if there are 40 thousand products in its catalog.

 
Postpone media content download
What is more important for the user to see first of all: beautiful pictures or the main content of the site? Pictures are certainly important, but it's better to show the structure and content first. To solve this problem, you can use the jQuery Lazy plugin. For it to work, you also need to use the jQuery library.

Plug-in connection in the website template

use Bitrix\Main\Page\Asset;
Asset::getInstance()->addJs(SITE_TEMPLATE_PATH . "/js/jquery.min.js");
Asset::getInstance()->addJs(SITE_TEMPLATE_PATH . "/js/jquery.lazyloading.min.js.js");
 

Initializing the plugin for the selected image class

$(function () { $('.lazy-img').Lazy(); });
 

The selected class must be added to the images .lazy-img, and replace the src attribute with data-src

<img data-src="<?=$arItem["PREVIEW_PICTURE"]["SRC"]?>" class="lazy-img"/>
 

To solve the problem with images being the background, instead of css properties background: url(/images/cloud.jpg) a class should be added.lazy-img and the data-src attribute for the block

<div class="lazy-img" data-src="/images/cloud.jpg"></div>


Configure cache lifetime
This setting determines the frequency of updating information on the page.

If the information on the site is updated once a day, it will be a mistake to leave the default cache lifetime (3600 s). It is necessary to set the value 24 hours (86400 s), otherwise every hour the visitor will re-download content from the server. 

It is important to take this parameter into account and set it taking into account the period of actual updating of information on the server.

 
Check that the memcached caching mechanism is enabled
Memcached is a service for caching data in RAM based on a hash table. This is the fastest way to cache, since the OS, if resources are available, will keep the last open files in memory. So make sure it is connected.
When we transfer sites to hosting, it is enabled by default in our template. Check in the site settings (dbconn) that this mechanism is enabled and used, because it also provides acceleration in operation.

 
Connect CDN
Bitrix provides the opportunity to use CDN (Content Delivery Network) technology, which allows you to upload images, styles and scripts from the server closest to the user. This increases the loading speed of the entire page.

To enable this option, go to Settings - 1C-Bitrix Cloud - Site Acceleration (CDN).

 

CDN Site Acceleration
 
After turning on the CDN, measure the download speed to exclude the opposite effect.

In the panel there is also a tool for measuring the loading speed of the site response. It measures the site loading speed of visitors.

This test shows four zones - “Very Fast", “Fast", “Slow” and “Very Slow", as well as the average loading time. Calculated for the last 1000 visitors to your site. The speed of the site actually shows how quickly your site was displayed for most of these 1000 visitors.

 
Bitrix test for site speed
Site speed test on Bitrix - Very fast


You can also test the download speed using the Google PageSpeed service or using developer tools in one of the modern browsers.
Optimize database settings
It is important to check several parameters in the DB settings.

 
CONFIGURE THE TYPE OF TABLES
If we are talking about modern projects that we transfer from other servers, check that the type of tables in the database is InnoDB.

Sites with this type of tables work faster and more reliably in terms of data security. This corresponds to the recommendations of Bitrix.

 
CONFIGURE THE BUFFER POOL SIZE PARAMETER
The general recommendation is to check and set the innodb buffer pool size approximately equal to the volume of the database.

 
Database Performance Monitor
 
In the BitrixVM template, it is configured automatically depending on the amount of RAM on the server.

 
CREATE FACETED INDEXES
This mechanism allows you to save time on the output of the query result.

For example, you decided to find information about the BMW M5 on the website. Without using a faceted index, the search would be carried out first by car brands, and then by model range. Faceted indexes pre-determine the possible options and the search will give the result faster. 
To create a faceted index, it is necessary that the product properties are present in the smart filter. After that, in the Content - Infoblocks - Faceted Indexes tab, you should start the index creation process.

 
Facet indexes of infoblocks

 
Enable composite site operation mode
Go to the website control panel. Go to the section

Settings > Product Settings > Composite Site > Settings > Composite

Click "Enable Composite"

You also need to set the cache lifetime for a day (86400 seconds), since 120 seconds will degrade performance.

Enabling nginx settings for the composite site via the command line utility

/opt/webdir/bin/bx-sites -o json -a composite --enable --site=default

(instead of default, if necessary, enter the name of the required site)

To disable, respectively:

/opt/webdir/bin/bx-sites -o json -a composite --disable --site=default


Disable unnecessary modules
There are modules in Bitrix that not everyone uses.  They are enabled by default, but not every site needs them. 
These include AD/LDAP integration, Push and Pull, Wiki, A/B testing, Web Analytics, Web Cluster, Web Messenger, Web Services, Business Process Designer, Workflow, Event Calendar, Report Designer, Idea Manager, Mobile Platform, Mobile Application for the Internet-stores, Training, Translation, Mail, Technical Support, Universal Lists, Scaling Management, as well as the integration module with Bitrix24. All of them negatively affect performance. Therefore, it is important to disable unused modules.

Another example of such a module is “Site24”, which allows you to quickly create simple sites on 1C–Bitrix without a web developer. It can also be disabled to speed up the work of the main site.

 
Track slow queries and bottlenecks in the structure of the site and database
Clients often come to us with such a problem: a website that had been working well before began to slow down.

For example, engineers analyze the load and see that most of the requests come from the MySQL service. At the same time, according to monitoring data for the previous days, there was no increased load before. 

First, engineers try to find out from the client what exactly has changed on the site. And if the client can't say for sure, then engineers use special tracking utilities to see which queries are running slowly or creating a high load on the database.

These are utilities:

mytop

mysqldumpslow

pt-query-digest (required if Percona Server is installed)

Sometimes you can see that resource-intensive cyclic queries have appeared on the site, which slow down the work.

We point them out to the customer. He understands what code changes they are caused by, and takes measures to correct the situation.

You can see some of this in the Bitrix admin panel yourself by enabling performance tracking and not contacting engineers. This will help you understand what changes on the site or in the logic of its operation lead to such slowing requests.

In the performance panel there is an opportunity to look at the indicators and analyze in detail the page loading speed.

Several mysql config options where to enable logging:

/etc/my.cnf
/etc/mysql/mariadb.conf.d/50-server.cnf
/etc/my.cnf.d/server.cnf
/etc/mysql/conf.d/bx_replica.cnf

Edit:
[mysqld]
slow_query_log = 1
long_query_time = 5 # required number in seconds
slow_query_log_file = /var/log/mysql/mysql-slow.log
 
It is recommended to turn on the diagnostic mode and walk around your site. Bitrix records this in the diagnostic module and shows what caused the delays. You can also view the most frequent and slowest database queries. And based on this data, decide what can be optimized in the site code.


WHAT KIND OF PERFORMANCE GAINS CAN YOU EXPECT?
When disabling unused modules, you can immediately get a performance gain of 10-20 points.

Optimizing MySQL queries can give a lot depending on the queries themselves. If the site was working very slowly, showing an index of 20-30, then after eliminating a slow query, the index can rise to 100 points.

Here is one example:

The customer contacted us with an online auto parts store with a large catalog. The site opened very slowly. We looked at the performance by pages.

The main page opened quickly, the transition through the sections, too. And when opening product cards, the site began to slow down. So, the product page was loaded for 25-30 seconds. We looked at the server – there was no special load at the same time.

They began to find out from the customer what he was doing on the site before the problem appeared. The customer remembered that he had included a module for applying watermarks to images. At first, the module worked fine, but then the disk began to overflow, and the customer disabled this module. Apparently, the module did not turn off completely and began to cause a huge delay when viewing products.

As a result, the client reinstalled and removed this module, after which the problem disappeared.


Rule: remember what you changed before the site began to slow down, even if it seemed to have nothing to do with slowing down its work.
 
When transferring sites to our hosting, we check all configuration settings and set them correctly, since sites are transferred to a prepared environment.

Additionally, engineers set parameters based on the specifics of each individual site to ensure its maximum performance.

For projects with a high load, sometimes you have to come up with separate solutions.

 
Use a scalable server cluster without buying an expensive solution
Recently, a media company, which predicted a large influx of visitors, had the task of increasing the server parameters to ensure that it could cope with the load.

We felt that even the maximum performance of one server would not be enough. The company asked us what can be done in this situation.

Of course, there is a boxed solution – the Bitrix Enterprise package, which allows you to host sites on multiple servers to cope with a high load. But this solution is very expensive, costing hundreds of thousands of rubles. The customer has not yet considered such investments. 

Therefore, we suggested creating a simple version of a scalable cluster without having to buy an expensive license.

We placed the content of the site on two servers called “php backends”, and added a separate server as a load balancer. He distributed the load between the two servers depending on the number of requests to the site. The database was moved to a separate server. 

Testing has shown that the maximum number of requests (RPS) that a cluster can handle has grown at least three times compared to a single server. At the same time, it became possible to further scale the cluster by adding additional backends.

With the next jump of visitors, such a cluster solution coped with the increased load, and the problem was solved.

Thus, the client received a cluster solution without having to pay hundreds of thousands of rubles for the purchase of an expensive license. The task was solved with an order of magnitude smaller budget.

 
The double effect of website acceleration
Increasing the speed of the site has a double effect.

Firstly, fast sites that “fly" have a “wow effect” for visitors. In comparison with them, competitors' sites seem even slower and delays when working with them begin to annoy. And the fast website that stands out against their background not only confirms that the company has invested in technology and thought about user convenience, but also creates an “attraction effect” - you want to stay longer on such a site, return more often and make more transactions.

And secondly, as noted by many of our customers accelerate page loading website increases its position in the search results Yandex and Google. And this is a direct commercial benefit.

We have tried in this article to write about those techniques for increasing the download speed that can be used independently, or to seek advice from our specialists. We will be happy to help speed up your Internet project as well.

If you have something to add to these methods or you want to share your own – write in the comments. It will be useful to everyone who works in this direction.





Information

Visitors who are in the group Guests they can't download files.
Log in to the site under your login and password or if you are a new user go through the process registrations on the website.

Comments:

This publication has no comments yet. You can be the first!

Information the publication:

Related News

27 December 2022
General questions 1c-bitrix
Which hosting should I

Which hosting should I choose? 1С-Bitrix

Read more
27 December 2022
General questions 1c-bitrix
1c-bitrix how to install

1c-bitrix how to install on the server Installing CMS 1C Bitrix in LEMP (Linux, Nginx, MariaDB, PHP 7) for CentOS

Read more
24 November 2022
WordPress»,WordPress Plugins
Perfmatters v1.9.2 -

Slow WordPress sites have higher bounce rates and fewer conversions. The Perfmatters plugin was created to speed

Read more
27 December 2022
General questions 1c-bitrix
How many sites can I

Read more

Information

Users of 🆅🅸🆂🅸🆃🅾🆁 are not allowed to comment this publication.

Site Search

Site Menu


☑ Websites Scripts

Calendar

«    December 2024    »
MonTueWedThuFriSatSun
 1
2345678
9101112131415
16171819202122
23242526272829
3031 

Advertisement

Survey on the website

Evaluate the work of the site
 

Statistics

  • +5 Total articles 6749
  • +13 Comments 4224
  • +29 Users : 6031