Using a Yandex Managed Service for Valkey™ cluster as a cache storage for 1C-Bitrix: Site Management
You can use a Yandex Managed Service for Valkey™ cluster as an external cache storage for a website on 1C-Bitrix: Site Management.
To set up caching:
If you no longer need the resources you created, delete them.
Getting started
Sign up for Yandex Cloud and create a billing account:
- Navigate to the management console
and log in to Yandex Cloud or create a new account. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVEorTRIAL_ACTIVEstatus. If you do not have a billing account, create one and link a cloud to it.
If you have an active billing account, you can create or select a folder for your infrastructure on the cloud page
Learn more about clouds and folders here.
Required paid resources
- VM instance: use of computing resources, storage, public IP address, and OS (see Yandex Compute Cloud pricing).
- Yandex Managed Service for Valkey™ cluster: computing resources, storage and backup size (see Yandex Managed Service for Valkey™ pricing).
This tutorial uses the trial version of 1C-Bitrix with a 30-day trial period. You can check the cost of the product software versions on the 1C-Bitrix
Set up your infrastructure
-
Create a network named
network-1cwith the Create subnets option disabled. -
In
network-1c, create a subnet with the following settings:- Name:
subnet-a. - Availability zone:
ru-central1-a. - CIDR:
192.168.0.0/24.
- Name:
-
Similarly, create another subnet, such as
subnet-b, innetwork-1cin theru-central1-bavailability zone with the192.168.1.0/24CIDR block. This subnet will be used for the Yandex Managed Service for Valkey™ cluster hosts, as the two cluster hosts cannot reside in the same availability zone. -
In
network-1c, create security groups:-
Named
bitrix-sg, for the VM in the cloud. Set the following rules for this security group:Traffic
directionDescription Port range Protocol Source /
Destination nameIPv4 CIDR Outbound ANYAllAnyPrefix0.0.0.0/0Inbound HTTP80TCPPrefix0.0.0.0/0Inbound EXT-HTTPS443TCPPrefix0.0.0.0/0Inbound SSH22TCPPrefix0.0.0.0/0 -
Named
valkey-sg, for the Yandex Managed Service for Valkey™ cluster. Set the following rules for this security group:Traffic
directionDescription Port range Protocol Source /
Destination nameIPv4 CIDR Outbound ANYAllAnyPrefix0.0.0.0/0Inbound EXT-HTTPS6379TCPPrefix0.0.0.0/0
-
-
Create a virtual machine with the following configuration in Compute Cloud:
-
Under Boot disk image, select a 1C-Bitrix image.
-
Under Network settings, set the following settings:
- Subnet:
network-1candsubnet-a. - Public IP address:
Auto. - Security groups:
bitrix-sg. - Internal IPv4 address:
Auto.
- Subnet:
-
-
Connect to the VM over SSH and install the PHP extensions to work with Valkey™:
sudo yum install -y php-pecl-redis6 php-pecl-igbinary && \ php -v && php -m | grep -E 'redis|igbinary'The 1C-Bitrix image already includes PHP (version 8.1 or later) with all the required extensions and repositories configured, so you do not need to install PHP separately. The
php-pecl-redis6extension is required to connect to the Yandex Managed Service for Valkey™ cluster, whilephp-pecl-igbinaryis used to serialize cache data. -
Install 1C-Bitrix: Site Management on the VM. Do it by going to
http://<VM_public_IP_address>/in your browser and following the installer instructions. -
Create a test website on 1C-Bitrix.
-
Create a Yandex Managed Service for Valkey™ cluster with the following configuration:
- Version:
9.1. - Hosts: At least two hosts to enable replication in the cluster.
- Persistence:
On replicas. - Network settings:
network-1cand thevalkey-sgsecurity group. - DBMS settings:
- Password:
defaultuser password. The password must contain at least eight characters. - Settings → Maxmemory policy:
ALLKEYS LRU. This setting will allow Valkey™ to delete the oldest keys when running out of memory.
- Password:
- WebSQL access: Enabled.
- Version:
-
If you do not have Terraform yet, install it.
-
Get the authentication credentials. You can add them to environment variables or specify them later in the provider configuration file.
-
Configure and initialize a provider. Instead of manually creating the provider configuration file, you can download it
. -
Place the configuration file in a separate working directory and specify the parameter values. If you have not added the authentication credentials to environment variables, specify them in the configuration file.
-
Download the yc-valkey-as-1c-cache-storage.tf
configuration file to the same working directory.This file describes:
-
Network.
-
Subnets.
-
Security groups.
-
Yandex Managed Service for Valkey™ cluster.
-
Virtual machine with public internet access and preinstalled 1C-Bitrix: Site Management distribution.
-
Settings for 1C-Bitrix: Site Management.
Note
Specific 1C-Bitrix settings may vary depending on your custom implementation. You can find cache configuration examples in the product documentation
.
-
-
In
yc-valkey-as-1c-cache-storage.tf, specify the value for thevalkey_passwordvariable, i.e., the Yandex Managed Service for Valkey™ cluster user password. -
Validate your Terraform configuration using this command:
terraform validateTerraform will display any configuration errors detected in your files.
-
Create the required infrastructure:
-
Run this command to view the intended changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
All the required resources will be created in the specified folder. You can check resource availability and their settings in the management console
. -
After you create the resources, the terminal will display the following connection settings:
valkey_endpoint: Endpoint for connection to the Yandex Managed Service for Valkey™ cluster.bitrix_vm_public_ip: Public IP address of the VM running 1C-Bitrix: Site Management.
Configure 1C-Bitrix
-
Connect to the VM running 1C-Bitrix over SSH.
-
Navigate to the website folder and create an additional configuration file named
bitrix/.settings_extra.php(missing from the VM by default). -
Specify Valkey™ as the caching option, Yandex Managed Service for Valkey™ cluster address, and the user password:
<?php return [ 'cache' => [ 'value' => [ 'type' => [ 'class_name' => '\Bitrix\Main\Data\CacheEngineRedis', ], 'redis' => [ 'servers' => [ [ 'host' => 'c-<cluster_ID>.rw.mdb.yandexcloud.net', 'port' => 6379, ], ], 'auth' => '<default_user_password>', 'serializer' => \Redis::SERIALIZER_IGBINARY ?? null, ], ], 'readonly' => true, ], ];You can get the cluster ID with the list of clusters in the folder.
Note
Specific 1C-Bitrix settings may vary depending on your custom implementation. You can find cache configuration examples in the product documentation
.
1C-Bitrix: Site Management is configured when you create the VM. No additional setup is required.
Check the result
-
Authenticate to your website and navigate to the control panel.
-
Open Settings → Productivity settings → Productivity panel.
-
On the Bitrix tab, make sure that caching is enabled with Valkey™ as storage.
-
Make sure data actually ends up in the cluster:
- In the management console
, select the folder containing the cluster. - Navigate
to Yandex Managed Service for Valkey™. - Click the cluster name and select the
Other → Monitoring tab. The page that opens will display performance charts for the cluster. - Make sure that clients have appeared, stored data and traffic are growing, and there is disk write activity on replicas due to enabled persistence.
- In the management console
Delete the resources you created
Delete the resources you no longer need to avoid paying for them:
- Delete the Yandex Managed Service for Valkey™ cluster.
- Delete the VM.
- If you reserved public static IP addresses, release and delete them.
-
In the terminal window, go to the directory containing the infrastructure plan.
Warning
Make sure the directory has no Terraform manifests with the resources you want to keep. Terraform deletes all resources that were created using the manifests in the current directory.
-
Delete resources:
-
Run this command:
terraform destroy -
Confirm deleting the resources and wait for the operation to complete.
All the resources described in the Terraform manifests will be deleted.
-