HAWK Load Balance API """"""""""""""""""""" Horizontally scaling the API services to accommodate increase of Active Users, HAWK Engines, and Resources. 1. Install hawk-data package on the secondary server. ``user@host#: yum install hawk-data`` 2. Copy the configuration files from the primary API server to the secondary server. From the secondary server run the following commands: .. code:: 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. 3. 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: .. code:: $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. 4. Edit memcached.conf on both servers. ``user@host#: vi /etc/nginx/conf.d/memcached.conf`` Add the Primary and Secondary host as shown below: .. code:: upstream memc_backend { server PrimaryAPI_Server:11211 max_fails=5; server SecondaryAPI_Server:11211 max_fails=5; keepalive 60; } 5. 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: .. code:: upstream fastcgi_backend { server PrimaryAPI_Server:9000 max_fails=5; server SecondaryAPI_Server:9000 max_fails=5; keepalive 60; } 6. 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`` 7. 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`` 8. It is now necessary to restart the services on both servers. .. code:: 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.