What is Load Balancing?
Load balancing is the process of distributing network traffic across multiple servers, computers, or other resources to optimize resource utilization, improve performance, and increase the availability and reliability of applications or services.
Can NitroPack operate with Load Balancing?
NitroPack can work with Load Balancing.
However, you must ensure that the server stack have Redis installed and configured.
Once you have ensured that Redis is a part of your network, there is one last step to take.
That step will differ depending on your website’s platform.
The configuration requires the following constants to be set within a website's wp-config.php file:
if (!defined("NITROPACK_USE_REDIS")) define("NITROPACK_USE_REDIS", false); // Set this to true to enable storing cache in Redisif (!defined("NITROPACK_REDIS_HOST")) define("NITROPACK_REDIS_HOST", "127.0.0.1"); // Set this to the IP of your Redis serverif (!defined("NITROPACK_REDIS_PORT")) define("NITROPACK_REDIS_PORT", 6379); // Set this to the port of your Redis serverif (!defined("NITROPACK_REDIS_PASS")) define("NITROPACK_REDIS_PASS", NULL); // Set this to the password of your redis server if authentication is neededif (!defined("NITROPACK_REDIS_DB")) define("NITROPACK_REDIS_DB", NULL); // Set this to the number of the Redis DB if you'd like not to use the default one
⚠️ Please note that the values should be adjusted according to your Redis configuration. You should be able to obtain this information from your hosting provider - the Redis IP address, port, passwords, and database (if any).
The OpenCart configuration has a few additional steps that need to be performed:
1. Navigate to the root folder of your website, and from there, go to system/config/nitropackio/
2. Look for the file default.php and open it.
There you will see a warning at the top stating:
“Never modify this file. Instead, create a new file called override.php in the same directory as this file. If a constant in override.php exists, it takes precedence over the constant in this file.”
3. Create a new file in the same directory called override.php (or use the existing one if already created).
4. Copy the section responsible for Redis and place it in the override.php file.
// Redis connection settings, used in case the NITROPACK_STORAGE_DRIVER is REDISif (!defined('NITROPACK_REDIS_HOSTNAME')) define('NITROPACK_REDIS_HOSTNAME', "127.0.0.1");if (!defined('NITROPACK_REDIS_PORT')) define('NITROPACK_REDIS_PORT', 6379);if (!defined('NITROPACK_REDIS_PASSWORD')) define('NITROPACK_REDIS_PASSWORD', NULL);if (!defined('NITROPACK_REDIS_DATABASE')) define('NITROPACK_REDIS_DATABASE', NULL);
⚠️ Please note that the values should be adjusted according to your Redis configuration. You should be able to obtain this information from your hosting provider - the Redis IP address, port, password, and database (if any).
To configure it, you must execute the following command via SSH.
php bin/magento setup:config:set --nitropack-cache-storage_type=<value> --nitropack-cache-redis_host=<value> --nitropack-cache-redis-pass=<value> --nitropack-cache-redis_db=<value> --nitropack-cache-redis-port=<value>
For further information, please refer to our dedicated article “Configure NitroPack for Magento with Redis.”