8. HAWK Load Balance API¶
Horizontally scaling the API services to accommodate increase of Active Users, HAWK Engines, and Resources.
Install hawk-data package on the secondary server.
user@host#: yum install hawk-data
Copy the configuration files from the primary API server to the secondary server.
From the secondary server run the following commands:
user@host#: scp -P40000 root@PrimaryAPI_Server:/opt/hawk/etc/hawk-eventd.cfg /opt/hawk/etc/hawk-eventd.cfg
user@host#: scp -P40000 root@PrimaryAPI_Server:/var/www/hawk-data/htdocs/API/1.1/config.php /var/www/hawk-data/htdocs/API/1.1/config.php
user@host#: scp -P40000 root@PrimaryAPI_Server:/etc/pki/tls/certs/localhost.crt /tmp/
user@host#: scp -P40000 root@PrimaryAPI_Server:/etc/pki/tls/private/localhost.key /tmp/
Warning
It is required on the steps below that servers are listed in the same order for both Primary and Secondary server’s configuration files.
Next we need to edit config.php on both servers.
user@host#: vi /var/www/hawk-data/htdocs/API/1.1/config.php
Find the memcached_hosts array, Add the Primary and Secondary host as shown below:
$CONFIG['MEMCACHED_HOSTS'] = array(
'PrimaryAPI_Server:11211',
'SecondaryAPI_Server:11211'
);
Note
The last item in the memcached hosts array does NOT have a comma ‘,’ at the end.
Edit memcached.conf on both servers.
user@host#: vi /etc/nginx/conf.d/memcached.conf
Add the Primary and Secondary host as shown below:
upstream memc_backend {
server PrimaryAPI_Server:11211 max_fails=5;
server SecondaryAPI_Server:11211 max_fails=5;
keepalive 60;
}
Edit php-fpm.conf on both servers.
user@host#: vi /etc/nginx/conf.d/php-fpm.conf
Add the Primary and Secondary host as shown below:
upstream fastcgi_backend {
server PrimaryAPI_Server:9000 max_fails=5;
server SecondaryAPI_Server:9000 max_fails=5;
keepalive 60;
}
Move the SSL Certificate and SSL Key to the correct location.
user@host#: mv /tmp/localhost.crt /etc/pki/tls/certs/localhost.crt
user@host#: mv /tmp/localhost.key /etc/pki/tls/private/localhost.key
Set the correct permissions for both the SSL Certificate and SSL Key.
user@host#: chmod 600 /etc/pki/tls/certs/localhost.crt
user@host#: chmod 600 /etc/pki/tls/private/localhost.key
It is now necessary to restart the services on both servers.
user@host#: service hawk-eventd restart
user@host#: service php-fpm restart
user@host#: service nginx restart
Note
If necessary, you can futher load balance the API services by repeating steps 1-8 for each additional server.