v3.11
Enable load balancing
Hideez Enterprise Server – Enable load balancing
In some cases, it is necessary to ensure that the HES server failure resistance.
In general, we can separate the fault tolerance of the database server (MySQL) and the fault tolerance of the HES itself.
As for the fault tolerance of databases, this process is described in detail in the relevant documentation - for example here.
Here we are talking only about HES, and then there is a small instruction on how to do it.
Consider an example where you have a separate MySQL server, three separate HES servers, and an Nginx proxy through which the end client has access to a group of HES servers.
Load balancing, in this case, will be that nginx will try to distribute requests evenly to the three HES servers, and fault tolerance is that if one of the servers crashes, users will continue to use the HES server.
In this case, in addition to our installation instructions, you need to do the following:
  • you need to allow remote user connection in the MySQL server settings. By default, only local users have access to the database, so the MySQL /etc/mysql/mysql.conf.d/mysqld.cnf configuration file needs to be modified - instead of
1
bind-address = 127.0.0.1
Copied!
you have to setup
1
bind-address = 0.0.0.0
Copied!
(you can simply add this line to the [mysqld] section if it is not there).
After restarting the MySQL server, you will be able to access it from remote HES servers.
  • when creating a MySQL user instead of a command
1
CREATE USER 'user'@'127.0.0.1' IDENTIFIED BY '<user_password>';
Copied!
should be used
1
CREATE USER 'user'@'%' IDENTIFIED BY '<user_password>';
Copied!
this will allow the user ‘user’ to connect to the database from any computer.
  • the following should be done when editing the /opt/HES/appsettings.Production.json file:
1) in the row
1
"ConnectionStrings":
2
{
3
"DefaultConnection":
4
"server=127.0.0.1;
5
port=3306;
6
database=db;
7
uid=user;
8
pwd=<user_password>"
9
},
Copied!
127.0.0.1 потрібно змінити на ip Вашого серверу MySQL
appsettings.Production.json should be the same on all servers!
However, if you want to visually "see" which server is currently processing your data, there may be slight differences between ServerFullName and ServerShortName.
1
"ServerFullName": "Hideez Enterprise Server",
2
"ServerShortName": "HES",
Copied!
2) by default, the HES server receives requests only from localhost, but since our proxy with nginx can be hosted at a different address, you need to allow access from other addresses. You can do this by adding the following lines to /opt/HES/appsettings.Production.json, after "AllowedHosts": "*" add the following (via comma):
1
,
2
"Kestrel": {
3
"Endpoints": {
4
"Http": {
5
"Url": "http://0.0.0.0:5000"
6
}
7
}
8
}
Copied!
  • in the nginx.conf file on the nginx server, you need to comment out the line
1
server localhost:5000;
Copied!
and uncomment lines
1
#ip_hash;
2
#server <ip or name of hes1 server>:5000 weight=3;
3
#server <ip or name of hes2 server>:5000;
4
#server <ip or name of hes1 server>:5000;
Copied!
and by entering the corresponding IP addresses of their three HES servers.
And of course it is necessary to adjust rules of firewalls. Note that MySQL typically uses TCP port 3306 and HES port TCP 5000.
Copy link