Multiple Redis instances
Can I run multiple Redis instances at Hipex?
At Hipex, we offer you much freedom and we always look at which configuration fits the best to your webshop. So, we offer you the necessary options in the field of Redis. If multiple elements make use of Redis within your webshop, you can choose for a single Redis instance with multiple databases, or multiple separate instances.
In this article, we explain the differences between both options.
Redis instance with multiple databases
If your webshop gets an average number of visitors each day, this option will be sufficient. A nice measure is when you purchase a Fox plan at Hipex, a single Redis instance with multiple databases is fine.
Then you can make use of the standard Redis socket, that can be found at the following location:
/home/<username>/domains/<domain-name>/var/run/redis.sock
This Redis instance can contain at most six databases, and are numbered from 0 to 5, the maximum memory use is 2GB.
When you use the instance you have to set in the configuration file which database you want to use within the instance. If several parts, such as frontend and page_cache, use Redis, you must give both parts their own database number.
Below, an example configuration of Magento 1 and Magento 2:
Configuration file Magento1:
<cache>
<backend>Cm_Cache_Backend_Redis</backend>
<backend_options>
<server>/home/[username]/domains/[domain-name]/var/run/redis.sock</server>
<port>0</port>
<database>0</database>
<force_standalone>0</force_standalone>
<connect_retries>1</connect_retries>
<read_timeout>10</read_timeout>
<automatic_cleaning_factor>0</automatic_cleaning_factor>
<compress_data>1</compress_data>
<compress_tags>1</compress_tags>
<compress_threshold>20480</compress_threshold>
<compression_lib>gzip</compression_lib>
</backend_options>
</cache>
<session_save>db</session_save>
<redis_session>
<host>/home/[username]/domains/[domain-name]/var/run/redis.sock</host>
<port>0</port>
<timeout>2.5</timeout>
<db>1</db>
<compression_threshold>0</compression_threshold>
<compression_lib>gzip</compression_lib>
<log_level>1</log_level>
<max_concurrency>6</max_concurrency>
<break_after_frontend>5</break_after_frontend>
<break_after_adminhtml>30</break_after_adminhtml>
<first_lifetime>600</first_lifetime>
<bot_first_lifetime>60</bot_first_lifetime>
<bot_lifetime>7200</bot_lifetime>
<disable_locking>0</disable_locking>
<min_lifetime>60</min_lifetime>
<max_lifetime>2592000</max_lifetime>
</redis_session>
Configuration file Magento2:
'cache' => [
'frontend' => [
'default' => [
'backend' => 'Cm_Cache_Backend_Redis',
'backend_options' => [
'server' => '/home/[username]/domains/[domain]/var/run/redis.sock',
'port' => '0',
'database' => '0'
],
],
],
],
'session' => [
'save' => 'redis',
'redis' => [
'host' => '/home/[username]/domains/[domain]/var/run/redis.sock',
'port' => '0',
'database' => '1',
'timeout' => '5',
'compression_threshold' => '2048',
'compression_library' => 'gzip',
'log_level' => '1',
'max_concurrency' => '20',
'break_after_frontend' => '5',
'break_after_adminhtml' => '30',
'first_lifetime' => '600',
'bot_first_lifetime' => '60',
'bot_lifetime' => '7200',
'disable_locking' => '0',
'min_lifetime' => '60',
'max_lifetime' => '2592000'
],
],
Multiple loose redis instances
As soon as your webshops do not have enough of 2GB, separate Redis instances can be set. There are many configuration options available, so you can determine how much memory the instance is allowed to use.
Please note: allocating too much memory can cause serious problems, as elements like MySQL, PHP, Varnish or other services do not get enough memory anymore. So, increase this with small steps and monitor well whether Redis has too much or too little memory.
For redis, you can choose between (unix)sockets and TCP/IP.